Skip to content

Fix Elasticsearch REST stable DB operation names#18988

Closed
trask wants to merge 3 commits into
open-telemetry:mainfrom
trask:fix-es-rest-low-level-operation
Closed

Fix Elasticsearch REST stable DB operation names#18988
trask wants to merge 3 commits into
open-telemetry:mainfrom
trask:fix-es-rest-low-level-operation

Conversation

@trask

@trask trask commented Jun 14, 2026

Copy link
Copy Markdown
Member

Built on top of #18989. Updates Elasticsearch REST low-level client instrumentation to infer stable low-cardinality database operation names from REST API paths while preserving old semconv operation names for legacy span naming.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates Elasticsearch REST low-level client instrumentation to derive stable, low-cardinality database operation names from REST API paths, while preserving legacy operation naming behavior for old semconv span names introduced/extended in #18989.

Changes:

  • Infer stable db.operation.name for Elasticsearch REST requests from API paths when endpoint metadata isn’t available.
  • Gate Elasticsearch span naming between stable operation names vs legacy naming using emitStableDatabaseSemconv().
  • Extend DB client incubator API/tests to support db.collection.name and to separate stable operation naming from old db.operation.

Reviewed changes

Copilot reviewed 13 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
instrumentation/elasticsearch/elasticsearch-rest-common-5.0/library/src/test/java/io/opentelemetry/instrumentation/elasticsearch/rest/common/v5_0/internal/ElasticsearchDbAttributesGetterTest.java Adds unit coverage for REST-path-based operation name inference and legacy behavior.
instrumentation/elasticsearch/elasticsearch-rest-common-5.0/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/common/v5_0/internal/ElasticsearchSpanNameExtractor.java Switches span naming between stable operation names and legacy naming based on semconv stability.
instrumentation/elasticsearch/elasticsearch-rest-common-5.0/library/src/main/java/io/opentelemetry/instrumentation/elasticsearch/rest/common/v5_0/internal/ElasticsearchDbAttributesGetter.java Implements stable operation-name inference from REST API path and keeps deprecated legacy operation accessor.
instrumentation/elasticsearch/elasticsearch-rest-7.0/library/src/test/java/io/opentelemetry/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java Updates library tests to assert span name/attrs under stable vs legacy semconv modes.
instrumentation/elasticsearch/elasticsearch-rest-7.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v7_0/ElasticsearchRest7Test.java Updates javaagent tests for stable operation names and metrics attribute presence.
instrumentation/elasticsearch/elasticsearch-rest-6.4/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v6_4/ElasticsearchRest6Test.java Same as above for ES 6.4 javaagent coverage.
instrumentation/elasticsearch/elasticsearch-rest-5.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/elasticsearch/rest/v5_0/ElasticsearchRest5Test.java Same as above for ES 5.0 javaagent coverage.
instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractorTest.java Updates/extends span-name tests for stable vs legacy paths and collection-vs-namespace targeting.
instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractorTest.java Updates extractor tests for new db.collection.name and old db.operation plumbing.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java Updates SQL getter docs and adds default getDbCollectionName hook.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java Refactors stable span-name target selection and adjusts old-vs-stable operation usage.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesGetter.java Adds deprecated getDbOperation() and default getDbCollectionName() to split old vs stable fields.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientAttributesExtractor.java Emits db.collection.name and sources old db.operation from getDbOperation().

@trask trask force-pushed the fix-es-rest-low-level-operation branch 4 times, most recently from 595561a to 39bb6d8 Compare June 15, 2026 04:10
@trask trask force-pushed the fix-es-rest-low-level-operation branch from 39bb6d8 to 846d23f Compare June 15, 2026 14:54
@trask trask requested a review from Copilot June 15, 2026 15:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

}

@Nullable
static String inferOperationName(String method, String endpoint) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

closing this PR, this is still not aligned with https://github.com/open-telemetry/semantic-conventions/blob/main/docs/db/elasticsearch.md, I think better not to emit than to make up heuristic here

@trask trask closed this Jun 15, 2026
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.

2 participants