-
Notifications
You must be signed in to change notification settings - Fork 1k
Deprecate DbClientCommonAttributesGetter #15139
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
2d367bb
Remove DbClientCommonAttributesExtractor
trask 8f0ce07
Merge branch 'main' into db-refactoring
trask 5ec1057
Merge remote-tracking branch 'upstream/main' into db-refactoring
trask a228abb
Fix copy paste
trask b3f6bc0
Extract onEndCommon
trask 3b3feaa
Extract onStartCommon
trask 109fd7a
spotless
trask File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
83 changes: 0 additions & 83 deletions
83
...telemetry/instrumentation/api/incubator/semconv/db/DbClientCommonAttributesExtractor.java
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -16,9 +16,12 @@ | |
| import io.opentelemetry.context.Context; | ||
| import io.opentelemetry.instrumentation.api.instrumenter.AttributesExtractor; | ||
| import io.opentelemetry.instrumentation.api.internal.SemconvStability; | ||
| import io.opentelemetry.instrumentation.api.internal.SpanKey; | ||
| import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider; | ||
| import io.opentelemetry.semconv.AttributeKeyTemplate; | ||
| import java.util.Collection; | ||
| import java.util.Map; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| /** | ||
| * Extractor of <a | ||
|
|
@@ -31,8 +34,7 @@ | |
| * statement parameters are removed. | ||
| */ | ||
| public final class SqlClientAttributesExtractor<REQUEST, RESPONSE> | ||
| extends DbClientCommonAttributesExtractor< | ||
| REQUEST, RESPONSE, SqlClientAttributesGetter<REQUEST, RESPONSE>> { | ||
| implements AttributesExtractor<REQUEST, RESPONSE>, SpanKeyProvider { | ||
|
Comment on lines
33
to
+37
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this change is ok since |
||
|
|
||
| // copied from DbIncubatingAttributes | ||
| private static final AttributeKey<String> DB_OPERATION = AttributeKey.stringKey("db.operation"); | ||
|
|
@@ -57,6 +59,7 @@ public static <REQUEST, RESPONSE> SqlClientAttributesExtractorBuilder<REQUEST, R | |
|
|
||
| private static final String SQL_CALL = "CALL"; | ||
|
|
||
| private final SqlClientAttributesGetter<REQUEST, RESPONSE> getter; | ||
| private final AttributeKey<String> oldSemconvTableAttribute; | ||
| private final boolean statementSanitizationEnabled; | ||
| private final boolean captureQueryParameters; | ||
|
|
@@ -66,23 +69,18 @@ public static <REQUEST, RESPONSE> SqlClientAttributesExtractorBuilder<REQUEST, R | |
| AttributeKey<String> oldSemconvTableAttribute, | ||
| boolean statementSanitizationEnabled, | ||
| boolean captureQueryParameters) { | ||
| super(getter); | ||
| this.getter = getter; | ||
| this.oldSemconvTableAttribute = oldSemconvTableAttribute; | ||
| // capturing query parameters disables statement sanitization | ||
| this.statementSanitizationEnabled = !captureQueryParameters && statementSanitizationEnabled; | ||
| this.captureQueryParameters = captureQueryParameters; | ||
| } | ||
|
|
||
| @SuppressWarnings("deprecation") // until old db semconv are dropped | ||
| @Override | ||
| public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) { | ||
| super.onStart(attributes, parentContext, request); | ||
|
|
||
| Collection<String> rawQueryTexts = getter.getRawQueryTexts(request); | ||
|
|
||
| if (rawQueryTexts.isEmpty()) { | ||
| return; | ||
| } | ||
|
|
||
| Long batchSize = getter.getBatchSize(request); | ||
| boolean isBatch = batchSize != null && batchSize > 1; | ||
|
|
||
|
|
@@ -118,7 +116,7 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST | |
| if (!SQL_CALL.equals(operation)) { | ||
| internalSet(attributes, DB_COLLECTION_NAME, sanitizedStatement.getMainIdentifier()); | ||
| } | ||
| } else { | ||
| } else if (rawQueryTexts.size() > 1) { | ||
| MultiQuery multiQuery = | ||
| MultiQuery.analyze(getter.getRawQueryTexts(request), statementSanitizationEnabled); | ||
| internalSet(attributes, DB_QUERY_TEXT, join("; ", multiQuery.getStatements())); | ||
|
|
@@ -136,6 +134,11 @@ public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST | |
|
|
||
| Map<String, String> queryParameters = getter.getQueryParameters(request); | ||
| setQueryParameters(attributes, isBatch, queryParameters); | ||
|
|
||
| // calling this last so explicit getDbOperationName(), getDbCollectionName(), | ||
| // getDbQueryText(), and getDbQuerySummary() implementations can override | ||
| // the parsed values from above | ||
| DbClientAttributesExtractor.onStartCommon(attributes, getter, request); | ||
| } | ||
|
|
||
| private void setQueryParameters( | ||
|
|
@@ -160,4 +163,23 @@ private static String join(String delimiter, Collection<String> collection) { | |
| } | ||
| return builder.toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public void onEnd( | ||
| AttributesBuilder attributes, | ||
| Context context, | ||
| REQUEST request, | ||
| @Nullable RESPONSE response, | ||
| @Nullable Throwable error) { | ||
| DbClientAttributesExtractor.onEndCommon(attributes, getter, response, error); | ||
| } | ||
|
|
||
| /** | ||
| * This method is internal and is hence not for public use. Its API is unstable and can change at | ||
| * any time. | ||
| */ | ||
| @Override | ||
| public SpanKey internalGetSpanKey() { | ||
| return SpanKey.DB_CLIENT; | ||
| } | ||
| } | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this change is ok since
DbClientCommonAttributesExtractorwasn't public