Emit stable Cassandra operation and collection attributes#18922
Merged
laurit merged 7 commits intoJun 10, 2026
Conversation
trask
force-pushed
the
cassandra-stable-db-collection-name
branch
2 times, most recently
from
June 6, 2026 23:12
88737be to
1d63f7b
Compare
Contributor
There was a problem hiding this comment.
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
SqlClientAttributesExtractorto optionally emit stabledb.operation.name/db.collection.namefrom 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. |
Contributor
There was a problem hiding this comment.
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 callsrecordCollectionName(). WhensetSingleOperationAndCollection(true)is enabled (e.g., Cassandra CQL), this causesdb.collection.nameto be missing forTRUNCATE ...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
force-pushed
the
cassandra-stable-db-collection-name
branch
5 times, most recently
from
June 9, 2026 14:21
4c66f9b to
82ca9d7
Compare
trask
force-pushed
the
cassandra-stable-db-collection-name
branch
2 times, most recently
from
June 9, 2026 19:58
f70d281 to
e59e856
Compare
trask
force-pushed
the
cassandra-stable-db-collection-name
branch
from
June 9, 2026 19:59
e59e856 to
2fc5ec9
Compare
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
force-pushed
the
cassandra-stable-db-collection-name
branch
from
June 9, 2026 22:49
2fc5ec9 to
41c4ba0
Compare
Co-authored-by: Copilot Autofix powered by AI <[email protected]>
trask
marked this pull request as ready for review
June 10, 2026 05:15
laurit
approved these changes
Jun 10, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Cassandra CQL only supports a single operation and single collection per query, so should capture
db.operation.nameanddb.collection.nameunder stable db semconv (e.g. similar to mongo).