Skip to content

Emit stable Cassandra operation and collection attributes#18922

Merged
laurit merged 7 commits into
open-telemetry:mainfrom
trask:cassandra-stable-db-collection-name
Jun 10, 2026
Merged

Emit stable Cassandra operation and collection attributes#18922
laurit merged 7 commits into
open-telemetry:mainfrom
trask:cassandra-stable-db-collection-name

Conversation

@trask

@trask trask commented Jun 6, 2026

Copy link
Copy Markdown
Member

Cassandra CQL only supports a single operation and single collection per query, so should capture db.operation.name and db.collection.name under stable db semconv (e.g. similar to mongo).

@trask
trask force-pushed the cassandra-stable-db-collection-name branch 2 times, most recently from 88737be to 1d63f7b Compare June 6, 2026 23:12
@trask
trask requested a review from Copilot June 7, 2026 04:04

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

This PR extends the SQL query analysis/sanitization pipeline and Cassandra instrumentations so that, when emitting stable DB semantic conventions, Cassandra spans/metrics can also include db.operation.name and db.collection.name (since CQL queries map cleanly to a single operation + single collection).

Changes:

  • Add support in SqlClientAttributesExtractor to optionally emit stable db.operation.name / db.collection.name from parsed query metadata via a new builder flag (setSingleOperationAndCollection(true)).
  • Enhance the JFlex SQL sanitizer-with-summary implementation to record operation + collection metadata alongside the existing query summary.
  • Enable the new behavior for Cassandra instrumentations and update related tests/metrics assertions accordingly.

Reviewed changes

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

Show a summary per file
File Description
instrumentation/hibernate/hibernate-common-3.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/hibernate/common/v3_3/OperationNameUtil.java Suppress deprecation warnings where old-semconv operation parsing is intentionally used.
instrumentation/couchbase/couchbase-common-2.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/couchbase/common/v2_0/CouchbaseRequestInfo.java Suppress deprecation warnings for old-semconv operation parsing usage.
instrumentation/cassandra/cassandra-common-4.0/testing/src/main/java/io/opentelemetry/cassandra/common/v4_0/AbstractCassandraTest.java Update Cassandra v4.0 test expectations and metrics attribute keys to include stable operation/collection.
instrumentation/cassandra/cassandra-4.4/testing/src/main/java/io/opentelemetry/testing/cassandra/v4_4/AbstractCassandra44Test.java Update Cassandra v4.4 reactive test expectations for stable operation/collection.
instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraTelemetryBuilder.java Enable “single operation + collection” extraction for Cassandra library instrumentation.
instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSingletons.java Enable “single operation + collection” extraction for Cassandra 4.0 javaagent instrumentation.
instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraClientTest.java Update Cassandra 3.0 javaagent tests and metrics assertions for stable operation/collection.
instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSingletons.java Enable “single operation + collection” extraction for Cassandra 3.0 javaagent instrumentation.
instrumentation/camel-2.20/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/camel/v2_20/decorators/CassandraTest.java Update Camel Cassandra decorator test to assert stable operation/collection attributes.
instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQueryAnalyzerTest.java Expand analyzer tests to validate stable operation/collection metadata extraction.
instrumentation-api-incubator/src/main/jflex/SqlSanitizerWithSummary.jflex Record operation and collection metadata during sanitization (in addition to query summary).
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlQuery.java Extend stable “with summary” SqlQuery creation to carry operation/collection metadata; deprecate getters for eventual encapsulation changes.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorBuilder.java Add setSingleOperationAndCollection(...) configuration knob.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java Emit stable db.operation.name / db.collection.name when singleOperationAndCollection is enabled.

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 14 out of 14 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

instrumentation-api-incubator/src/main/jflex/SqlSanitizerWithSummary.jflex:614

  • Truncate.handleIdentifier() appends the target table name to the summary, but never calls recordCollectionName(). When setSingleOperationAndCollection(true) is enabled (e.g., Cassandra CQL), this causes db.collection.name to be missing for TRUNCATE ... statements even though a single table identifier is available.
    void handleIdentifier() {
      String text = yytext();
      // Include TABLE keyword in summary
      if (text.equalsIgnoreCase("TABLE")) {
        if (!tableCaptured) {
          appendTargetToSummary();
          refineOperationName("TABLE");
          tableCaptured = true;
        }
        return;
      }
      if (!identifierCaptured) {
        appendTargetToSummary();
        identifierCaptured = true;
      }

@trask
trask force-pushed the cassandra-stable-db-collection-name branch 5 times, most recently from 4c66f9b to 82ca9d7 Compare June 9, 2026 14:21
@trask
trask requested a review from Copilot June 9, 2026 18:41

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 14 out of 14 changed files in this pull request and generated 1 comment.

@trask
trask requested a review from Copilot June 9, 2026 19:52
@trask
trask force-pushed the cassandra-stable-db-collection-name branch 2 times, most recently from f70d281 to e59e856 Compare June 9, 2026 19:58

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 15 out of 15 changed files in this pull request and generated no new comments.

@trask
trask force-pushed the cassandra-stable-db-collection-name branch from e59e856 to 2fc5ec9 Compare June 9, 2026 19:59
trask added 2 commits June 9, 2026 15:49
The stable semconv SQL analyzer now preserves the case of operation keywords in
query summaries, but two parameterized test expectations still assumed uppercase
summary operations for lowercase input. Update those expectations to match the
preserved-case behavior.

Validation: .\gradlew.bat :instrumentation-api-incubator:testStableSemconv
@trask
trask force-pushed the cassandra-stable-db-collection-name branch from 2fc5ec9 to 41c4ba0 Compare June 9, 2026 22:49
@trask
trask requested a review from Copilot June 10, 2026 01:00

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 14 out of 14 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 14 out of 14 changed files in this pull request and generated no new 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 14 out of 14 changed files in this pull request and generated 1 comment.

Co-authored-by: Copilot Autofix powered by AI <[email protected]>
@trask
trask marked this pull request as ready for review June 10, 2026 05:15
@trask
trask requested a review from a team as a code owner June 10, 2026 05:15
@laurit
laurit merged commit 441d0ea into open-telemetry:main Jun 10, 2026
182 of 184 checks passed
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.

3 participants