Skip to content

Capture Cassandra batch queries#18964

Merged
trask merged 10 commits into
open-telemetry:mainfrom
trask:cassandra-mixed-batch-sanitization
Jun 12, 2026
Merged

Capture Cassandra batch queries#18964
trask merged 10 commits into
open-telemetry:mainfrom
trask:cassandra-mixed-batch-sanitization

Conversation

@trask

@trask trask commented Jun 11, 2026

Copy link
Copy Markdown
Member

Summary

  • capture Cassandra batch query texts and batch size for 3.0, 4.0, and 4.4 instrumentation
  • support per-query parameterization so mixed Cassandra batches preserve parameterized query text while sanitizing literal query text

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 incubating SQL semantic-conventions extractor to support per-query parameterization (via an indexed isParameterizedQuery(request, queryIndex) hook) so batch requests with mixed parameterization can sanitize only the non-parameterized entries, and updates Cassandra (3.0/4.0/4.4) instrumentation to supply per-entry query texts and batch size.

Changes:

  • Add SqlClientAttributesGetter.isParameterizedQuery(request, queryIndex) (and update extractors) to enable per-query sanitization within multi-query requests.
  • Update Cassandra 3.0/4.0/4.4 request capture to support multi-query/batch query texts, per-entry parameterization, and db.operation.batch.size.
  • Add tests covering same-query and mixed-query Cassandra batches and mixed-parameterized multi-query extraction.

Reviewed changes

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

Show a summary per file
File Description
instrumentation/vertx/vertx-sql-client/vertx-sql-client-common-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/sqlclient/common/v4_0/VertxSqlClientAttributesGetter.java Implements indexed parameterization hook for Vert.x SQL client requests.
instrumentation/r2dbc-1.0/library/src/main/java/io/opentelemetry/instrumentation/r2dbc/v1_0/internal/R2dbcSqlAttributesGetter.java Implements indexed parameterization hook for R2DBC executions.
instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcAttributesGetter.java Implements indexed parameterization hook for JDBC requests.
instrumentation/cassandra/cassandra-common-4.0/testing/src/main/java/io/opentelemetry/cassandra/common/v4_0/AbstractCassandraTest.java Adds batch tests validating query text capture/sanitization and batch size attribute.
instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/TracingCqlSession.java Switches Cassandra request creation to statement-aware factory for batch support.
instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraSqlAttributesGetter.java Exposes multi-query texts, batch size, and indexed parameterization for 4.4 library.
instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraRequest.java Extends request model to hold multiple query texts, per-entry parameterization, and batch size (with deprecations).
instrumentation/cassandra/cassandra-4.4/library/src/main/java/io/opentelemetry/instrumentation/cassandra/v4_4/CassandraAttributesExtractor.java Adjusts extractor to use new session accessor.
instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/TracingCqlSession.java Switches Cassandra request creation to statement-aware factory for batch support (javaagent).
instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraSqlAttributesGetter.java Exposes multi-query texts, batch size, and indexed parameterization for 4.0 javaagent.
instrumentation/cassandra/cassandra-4.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v4_0/CassandraRequest.java Extends request model to hold multiple query texts, per-entry parameterization, and batch size (javaagent).
instrumentation/cassandra/cassandra-3.0/javaagent/src/test/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraClientTest.java Adds batch tests validating query text capture/sanitization and batch size attribute (3.0).
instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/TracingSession.java Switches Cassandra request creation to statement-aware factory for batch support (3.0).
instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraSqlAttributesGetter.java Exposes multi-query texts, batch size, and indexed parameterization for 3.0 javaagent.
instrumentation/cassandra/cassandra-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/cassandra/v3_0/CassandraRequest.java Extends request model to hold multiple query texts, per-entry parameterization, and batch size (3.0).
instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractorTest.java Adds test coverage for mixed-parameterized multi-query sanitization behavior.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesGetter.java Deprecates old parameterization hook and adds indexed parameterization hook.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/SqlClientAttributesExtractor.java Updates sanitization logic to evaluate parameterization per query index in batches.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/MultiQuery.java Refactors multi-query analysis to a builder to support per-entry sanitized/raw text selection.
instrumentation-api-incubator/src/main/java/io/opentelemetry/instrumentation/api/incubator/semconv/db/DbClientSpanNameExtractor.java Updates multi-query helper invocation after MultiQuery refactor.

@trask trask force-pushed the cassandra-mixed-batch-sanitization branch from 7d9a761 to bfd85a2 Compare June 11, 2026 16:59
@trask trask force-pushed the cassandra-mixed-batch-sanitization branch from bfd85a2 to 2af0f4b Compare June 11, 2026 17:03
@trask trask requested a review from Copilot June 11, 2026 17:11

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

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>

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

@trask trask force-pushed the cassandra-mixed-batch-sanitization branch from ef0305e to bdbada8 Compare June 11, 2026 18:33
@trask trask requested a review from Copilot June 11, 2026 20:59

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

@trask trask force-pushed the cassandra-mixed-batch-sanitization branch 6 times, most recently from 1e74aaf to 84a4219 Compare June 11, 2026 22:23
@trask trask requested a review from Copilot June 12, 2026 02:50

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

@trask trask changed the title Support mixed Cassandra batch query sanitization Capture Cassandra batch query telemetry Jun 12, 2026
@trask trask force-pushed the cassandra-mixed-batch-sanitization branch from 84a4219 to 9c50ffd Compare June 12, 2026 03:26
@trask trask force-pushed the cassandra-mixed-batch-sanitization branch from 9c50ffd to 91d3530 Compare June 12, 2026 03:58
@trask trask changed the title Capture Cassandra batch query telemetry Capture Cassandra batch queries Jun 12, 2026
@trask trask requested a review from Copilot June 12, 2026 04:02

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

@trask trask marked this pull request as ready for review June 12, 2026 04:47
@trask trask requested a review from a team as a code owner June 12, 2026 04:47
@trask trask added this to the v2.29.0 milestone Jun 12, 2026
@trask trask enabled auto-merge (squash) June 12, 2026 14:44
@trask trask disabled auto-merge June 12, 2026 15:13
trask added 2 commits June 12, 2026 08:45
Cassandra batch setup only emits traces for the three executed schema
statements; preparing the batch statement does not create a trace, so the
tests timed out while draining four traces before the real assertion.

Pulsar latest dependencies can emit extra receive-only spans for multi-topic
consumption, and one-message batch receive spans may report batch count instead
of an individual message id. The test now asserts the required publish,
receive, and process spans directly instead of relying on an exact trace count.

Validation:
.\gradlew.bat :instrumentation:cassandra:cassandra-3.0:javaagent:test --tests io.opentelemetry.javaagent.instrumentation.cassandra.v3_0.CassandraClientTest.batchStatementWithSameQuery --tests io.opentelemetry.javaagent.instrumentation.cassandra.v3_0.CassandraClientTest.batchStatementWithDifferentQueries :instrumentation:cassandra:cassandra-4.0:javaagent:test --tests io.opentelemetry.javaagent.instrumentation.cassandra.v4_0.CassandraTest.batchStatementWithSameQuery --tests io.opentelemetry.javaagent.instrumentation.cassandra.v4_0.CassandraTest.batchStatementWithDifferentQueries :instrumentation:cassandra:cassandra-4.4:javaagent:test --tests io.opentelemetry.javaagent.instrumentation.cassandra.v4_4.CassandraTest.batchStatementWithSameQuery --tests io.opentelemetry.javaagent.instrumentation.cassandra.v4_4.CassandraTest.batchStatementWithDifferentQueries :instrumentation:cassandra:cassandra-4.4:library:test --tests io.opentelemetry.instrumentation.cassandra.v4_4.CassandraTest.batchStatementWithSameQuery --tests io.opentelemetry.instrumentation.cassandra.v4_4.CassandraTest.batchStatementWithDifferentQueries :instrumentation:pulsar:pulsar-2.8:javaagent:test --tests io.opentelemetry.javaagent.instrumentation.pulsar.v2_8.PulsarClientTest.testConsumeMultiTopics
.\gradlew.bat :instrumentation:pulsar:pulsar-2.8:javaagent:test -PtestLatestDeps=true --tests io.opentelemetry.javaagent.instrumentation.pulsar.v2_8.PulsarClientTest.testConsumeMultiTopics
.\gradlew.bat :instrumentation:cassandra:cassandra-3.0:javaagent:spotlessCheck :instrumentation:cassandra:cassandra-common-4.0:testing:spotlessCheck :instrumentation:pulsar:pulsar-2.8:javaagent:spotlessCheck
@trask trask merged commit a306dde into open-telemetry:main Jun 12, 2026
97 checks passed
@trask trask deleted the cassandra-mixed-batch-sanitization branch June 12, 2026 17:01
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