Unify database batch tests into parameterized scenario tests#19019
Draft
trask wants to merge 31 commits into
Draft
Unify database batch tests into parameterized scenario tests#19019trask wants to merge 31 commits into
trask wants to merge 31 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR consolidates per-case batch telemetry tests across multiple database instrumentations into @ParameterizedTest methods driven by BatchScenario holder classes. The goal is to standardize how batch telemetry shape is tested (BATCH-prefixed span names/summaries, db.operation.batch.size, joined db.query.text), making future changes to batch behavior easier to validate in one place per module.
Changes:
- Replaced individual
@Testmethods for batch variants (empty, single, two-same-op, two-different-ops) with@ParameterizedTest/@MethodSourcedriven by aBatchScenariodata class in each module (JDBC, DynamoDB v1.11 & v2.2, Cassandra 3.0 & 4.0, R2DBC, Vert.x SQL 4.0 & 5.0, Redisson). - JDBC batch tests were narrowed from multi-driver (h2+sqlite) to h2-only and stable-semconv-only, since batch telemetry comes from shared SQL extractors and is database-agnostic.
- AWS SDK 2.2 batch test was rewritten from using the shared
assertDynamoDbRequesthelper to inline attribute construction, adding a new "empty batch" scenario and conditional metric assertions.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
instrumentation/jdbc/testing/.../AbstractJdbcInstrumentationTest.java |
Adds testStatementBatch parameterized test with BatchScenario builder; removes testBatch, testMultiBatch, testSingleItemBatch, and testBatchImpl |
instrumentation/aws-sdk/aws-sdk-2.2/testing/.../AbstractAws2ClientCoreTest.java |
Unifies testBatchGetItem* and testBatchWriteItem* into batchOperation with inline assertions, adds empty-batch scenario |
instrumentation/aws-sdk/aws-sdk-1.11/testing/.../AbstractDynamoDbClientTest.java |
Unifies 4 batch tests into batchOperation with 6 scenarios (empty/single/two × get/write) |
instrumentation/cassandra/cassandra-common-4.0/testing/.../AbstractCassandraTest.java |
Unifies batchStatementWithSameQuery and batchStatementWithDifferentQueries into batchStatement |
instrumentation/cassandra/cassandra-3.0/.../CassandraClientTest.java |
Same refactoring as Cassandra 4.0 but for v3 driver API |
instrumentation/r2dbc-1.0/testing/.../AbstractR2dbcStatementTest.java |
Converts testBatchQueries to parameterized batchQueries with single/twoSameOp scenarios |
instrumentation/vertx/.../v4_0/VertxSqlClientTest.java |
Converts testBatch to parameterized with single/twoSameOp scenarios |
instrumentation/vertx/.../v5_0/VertxSqlClientTest.java |
Same as Vert.x 4.0 |
instrumentation/redisson/.../AbstractRedissonClientTest.java |
Unifies batchCommand and mixedBatchCommand into parameterized batchCommand |
…trumentations db.operation.batch.size is now captured for every batch execution including empty batches (size 0). It is only omitted when the batch size is 1, which is reported as a non-batch operation. This change applies uniformly to JDBC, R2DBC, Cassandra (3.0/4.0/4.4), Vert.x SQL client (4.0/5.0), and AWS DynamoDB SDK (1.11/2.2). Key changes: - Core gate in SqlClientAttributesExtractor/DbClientAttributesExtractor changed from batchSize > 1 to batchSize != 1 - JDBC javaagent tracks empty batches to report size 0 (option B) - R2DBC uses ExecutionType.BATCH to distinguish from Statement executions - Vert.x batch size computed for size != 1 - DynamoDB extractors emit 0 for empty BatchGetItem/BatchWriteItem - All test matrices updated to assert batchSize(0) on empty scenarios
For stable semconv, inspect BatchWriteItem requests to determine the actual operation type: - Single PutRequest -> PutItem - Single DeleteRequest -> DeleteItem - Multiple PutRequests -> BATCH PutItem - Multiple DeleteRequests -> BATCH DeleteItem - Mixed Put/Delete -> BATCH This aligns DynamoDB with SQL/Cassandra batch naming conventions where specific operation names are used when all items in a batch perform the same operation type. Also adds test coverage for all BatchWriteItem scenarios.
R2DBC batch getter tests built a mock query execution with a batch size but without marking it as an R2DBC batch, so stable semconv batch attributes were not available. AWS SDK 1.11 looked up DynamoDB WriteRequest accessors with an exact Object return type, so PutRequest/DeleteRequest methods were not found and batch write operations were misclassified. Mark the R2DBC mock as a batch and resolve AWS v1.11 write accessors without requiring a specific return type. Validation: ./gradlew :instrumentation:r2dbc-1.0:library:testStableSemconv --tests "io.opentelemetry.instrumentation.r2dbc.v1_0.R2dbcSqlAttributesGetterTest" --rerun --no-daemon ./gradlew :instrumentation:aws-sdk:aws-sdk-1.11:library:testStableSemconv --tests "*batchOperation*" --rerun --no-daemon ./gradlew :instrumentation:aws-sdk:aws-sdk-1.11:javaagent:testStableSemconv --tests "*batchOperation*" --rerun --no-daemon ./gradlew :instrumentation:r2dbc-1.0:library:spotlessApply :instrumentation:aws-sdk:aws-sdk-1.11:library:spotlessApply --no-daemon
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.
Description
Consolidates the per-case batch tests across the database instrumentations that emit
db.operation.batch.sizeinto a single@ParameterizedTestdriven by a smallBatchScenarioholder, locking down the shape of batch telemetry (BATCH-prefixed span names/summaries,db.operation.batch.size, joineddb.query.text).Each unified test covers the relevant cases:
db.operation.batch.size)BATCH <op>span/summary,db.operation.batch.size = 2BATCHspan/summary, joined query textModules updated:
Statement)Notes
INSERT ks.users, RedissonSET), not a batch — so thesinglecase is dropped where that path diverges and kept where the size-1 span still looks batch-shaped.executeLargeBatch/prepared batch, Redisson large/atomic batch) are left as separate tests.Opening as a draft to run CI across the Docker-based integration suites.