Skip to content

Conversation

@trask
Copy link
Member

@trask trask commented Oct 24, 2025

Semconv doesn't have this concept.

HttpCommonAttributesGetter makes sense b/c it's common attributes across both client and server.

But in semconv, Sql "extends" Db semantic conventions, and so I think our getter hierarchy should do the same.

In practice, this means that Sql getter now has things like getDbOperationName(), which I think is probably good, though we can default them to null in the Sql getter interface to make them not required.

Related to #12608

@trask trask changed the title Remove DbClientCommonAttributesExtractor Remove DbClientCommonAttributesGetter Oct 24, 2025
@trask trask changed the title Remove DbClientCommonAttributesGetter Deprecate DbClientCommonAttributesGetter Oct 24, 2025
@trask trask marked this pull request as ready for review October 25, 2025 18:13
@trask trask requested a review from a team as a code owner October 25, 2025 18:13
@Override
public void onStart(AttributesBuilder attributes, Context parentContext, REQUEST request) {
super.onStart(attributes, parentContext, request);
// Common attributes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could consider placing the common part to util class or perhaps even a static package private method in DbClientAttributesExtractor that could also be called from here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this worked out, ptal

import io.opentelemetry.instrumentation.api.internal.SpanKeyProvider;
import javax.annotation.Nullable;

abstract class DbClientCommonAttributesExtractor<
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can delete this right away since not public

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could also consider keeping the common extractor, since it is just an implementation detail, deleting it is fine too

Comment on lines 33 to +41
public final class SqlClientAttributesExtractor<REQUEST, RESPONSE>
extends DbClientCommonAttributesExtractor<
REQUEST, RESPONSE, SqlClientAttributesGetter<REQUEST, RESPONSE>> {
implements AttributesExtractor<REQUEST, RESPONSE>, SpanKeyProvider {
Copy link
Member Author

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 DbClientCommonAttributesExtractor wasn't public

Comment on lines 27 to 55
/**
* SqlClientAttributesExtractor will try to populate db.operation.name based on {@link
* #getRawQueryTexts(REQUEST)}, but this can be used to explicitly provide the operation name.
*/
@Override
@Nullable
default String getDbOperationName(REQUEST request) {
return null;
}

/**
* SqlClientAttributesExtractor will try to populate db.operation.name based on {@link
* #getRawQueryTexts(REQUEST)}, but this can be used to explicitly provide the operation name.
*/
@Override
@Nullable
default String getDbQueryText(REQUEST request) {
return null;
}

/**
* SqlClientAttributesExtractor will try to populate db.operation.name based on {@link
* #getRawQueryTexts(REQUEST)}, but this can be used to explicitly provide the operation name.
*/
@Override
@Nullable
default String getDbQuerySummary(REQUEST request) {
return null;
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these methods have same defaults in super interface, but we have comments to remove the defaults in the super interface at which time we'll still want them here

Comment on lines -28 to +35
extends DbClientCommonAttributesExtractor<
REQUEST, RESPONSE, DbClientAttributesGetter<REQUEST, RESPONSE>> {
implements AttributesExtractor<REQUEST, RESPONSE>, SpanKeyProvider {
Copy link
Member Author

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 DbClientCommonAttributesExtractor wasn't public

@otelbot-java-instrumentation
Copy link
Contributor

🔧 The result from spotlessApply was committed to the PR branch.

@trask trask merged commit 5a03eca into open-telemetry:main Nov 10, 2025
89 checks passed
@trask trask deleted the db-refactoring branch November 10, 2025 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants