-
Notifications
You must be signed in to change notification settings - Fork 879
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Statically import semconv constants in tests (#13026)
- Loading branch information
Showing
13 changed files
with
268 additions
and
226 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#!/bin/bash -e | ||
|
||
# shellcheck disable=SC2044 | ||
for file in $(find instrumentation instrumentation-api -name '*Test.java'); do | ||
echo "Processing $file" | ||
|
||
# stable semconv | ||
|
||
negative_lookbehind='(?<!import static io.opentelemetry.semconv.)' | ||
|
||
for class in "ClientAttributes" "ErrorAttributes" "ExceptionAttributes" "HttpAttributes" "JvmAttributes" "NetworkAttributes" "OtelAttributes" "ServerAttributes" "ServiceAttributes" "TelemetryAttributes" "UrlAttributes" "UserAgentAttributes"; do | ||
for attr in $(perl -ne "print \"\$1\n\" if /$negative_lookbehind$class\.([A-Z][A-Z][A-Z_]*)/" "$file" | sort -u); do | ||
perl -i -pe "s/$negative_lookbehind$class\.$attr/$attr/" "$file" | ||
sed -i "0,/^import/{s/^import/import static io.opentelemetry.semconv.$class.$attr;\nimport/}" "$file" | ||
done | ||
done | ||
|
||
# incubating semconv | ||
|
||
negative_lookbehind='(?<!import static io.opentelemetry.semconv.incubating.)' | ||
|
||
for class in "AwsIncubatingAttributes" "DbIncubatingAttributes" "HttpIncubatingAttributes" "MessagingIncubatingAttributes"; do | ||
for attr in $(perl -ne "print \"\$1\n\" if /$negative_lookbehind$class\.([A-Z][A-Z][A-Z_]*)/" "$file" | sort -u); do | ||
perl -i -pe "s/$negative_lookbehind$class\.$attr/$attr/" "$file" | ||
sed -i "0,/^import/{s/^import/import static io.opentelemetry.semconv.incubating.$class.$attr;\nimport/}" "$file" | ||
done | ||
done | ||
done | ||
|
||
./gradlew spotlessApply |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.