Skip to content

Handle explicit empty database batches#19036

Closed
trask wants to merge 1 commit into
open-telemetry:mainfrom
trask:split-core-db-batch-semantics-19019
Closed

Handle explicit empty database batches#19036
trask wants to merge 1 commit into
open-telemetry:mainfrom
trask:split-core-db-batch-semantics-19019

Conversation

@trask

@trask trask commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary

Core behavioral changes from #19019, reflecting clarification in open-telemetry/semantic-conventions#3811.

This updates shared DB semconv handling so explicit empty batches (db.operation.batch.size = 0) are treated as batches for stable span names and db.query.summary.

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 updates shared DB semconv handling to treat explicit empty batches (db.operation.batch.size = 0) as batches for stable span names and db.query.summary. Previously, only batchSize > 1 was considered a batch; now any non-null, non-one value triggers batch behavior. The PR also extends MultiQuery to track per-query operation names and collection names for the singleOperationAndCollection feature.

Changes:

  • Updated batch condition from batchSize > 1 to batchSize != 1 consistently across DbClientAttributesExtractor, SqlClientAttributesExtractor, and DbClientSpanNameExtractor.
  • Extended MultiQuery with operationName/collectionName fields and emitted them in the multi-query path when singleOperationAndCollection is enabled.
  • Added comprehensive test coverage for empty batch (batchSize=0) scenarios and the multi-query singleOperationAndCollection behavior.

Reviewed changes

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

Show a summary per file
File Description
DbClientAttributesExtractor.java Updated batch condition to batchSize != 1; renamed intermediate variable to emitBatchSize for clarity.
SqlClientAttributesExtractor.java Same batch condition update; added DB_OPERATION_NAME/DB_COLLECTION_NAME emission from MultiQuery in multi-query path.
DbClientSpanNameExtractor.java Updated isBatch() method to treat size 0 as batch; added early "BATCH" return for empty query texts in batch context.
MultiQuery.java Added operationName/collectionName fields, builder tracking via UniqueValue, and "BATCH"-prefixed construction in build().
SqlClientAttributesExtractorTest.java Added tests for empty batch attributes and multi-query batch with singleOperationAndCollection.
DbClientSpanNameExtractorTest.java Added tests for empty batch span names and default mock setup for batch size.

@trask trask marked this pull request as ready for review June 18, 2026 16:01
@trask trask requested a review from a team as a code owner June 18, 2026 16:01
@trask trask marked this pull request as draft June 18, 2026 17:08
@trask

trask commented Jun 18, 2026

Copy link
Copy Markdown
Member Author

Closing, going to focus on getting the test-only improvements in first, then come back and add this so we can see effect on tests at the same time.

@trask trask closed this Jun 18, 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