Skip to content

influxdb-2.4: capture db.operation.batch.size for BatchPoints writes#19279

Open
bhuvan-somisetty wants to merge 2 commits into
open-telemetry:mainfrom
bhuvan-somisetty:influxdb-batch-size
Open

influxdb-2.4: capture db.operation.batch.size for BatchPoints writes#19279
bhuvan-somisetty wants to merge 2 commits into
open-telemetry:mainfrom
bhuvan-somisetty:influxdb-batch-size

Conversation

@bhuvan-somisetty

Copy link
Copy Markdown
Contributor

Resolves #19264

Description

influxdb-2.4 records db.operation.name for writes, but a write through InfluxDB.write(BatchPoints) sends a whole batch of points in a single request and the point count was never captured. This meant a batch write of, say, 500 points looked identical on the span to a write of a single point.

db.operation.batch.size is a stable database semantic-convention attribute, and the point count is readily available on the BatchPoints object the instrumentation already has in hand (BatchPoints.getPoints()). This follows the same pattern already used by the hbase-client instrumentation for its batch operations.

Changes

  • Added a nullable batchSize field to InfluxDbOperation (the @AutoValue request object).
  • In InfluxDbImplInstrumentation.InfluxDbModifyAdvice#onEnter, when arg0 instanceof BatchPoints, read ((BatchPoints) arg0).getPoints().size() and pass it into InfluxDbOperation.create(...). It stays null for the UDP / createDatabase / deleteDatabase paths, where there is no batch.
  • Overrode getDbOperationBatchSize in InfluxDbAttributesGetter to return that value.
  • Updated InfluxDbClientTest#testQueryAndModifyWithOneArgument to assert db.operation.batch.size = 2 on the write span for the existing two-point BatchPoints write.

No new configuration is needed. The shared DbClientAttributesExtractor already emits db.operation.batch.size under stable semconv and treats a size of 1 as a non-batch operation, so single-point writes are unaffected.

Test plan

  • ./gradlew :instrumentation:influxdb-2.4:javaagent:compileJava :instrumentation:influxdb-2.4:javaagent:compileTestJava
  • ./gradlew :instrumentation:influxdb-2.4:javaagent:spotlessCheck :instrumentation:influxdb-2.4:javaagent:checkstyleMain :instrumentation:influxdb-2.4:javaagent:checkstyleTest
  • ./gradlew :instrumentation:influxdb-2.4:javaagent:test (requires Docker/testcontainers, run in CI)

A write through InfluxDB.write(BatchPoints) sends a whole batch of
points in a single request, but the point count was never recorded on
the span. Read BatchPoints.getPoints().size() in the write advice and
expose it via InfluxDbAttributesGetter#getDbOperationBatchSize, the
same pattern already used by the hbase-client instrumentation.
Copilot AI review requested due to automatic review settings July 20, 2026 09:35
@bhuvan-somisetty
bhuvan-somisetty requested a review from a team as a code owner July 20, 2026 09:35
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Jul 20, 2026

Copy link
Copy Markdown

Pull request dashboard status

Status last refreshed: 2026-07-21 03:17:02 UTC.

  • Waiting on: Reviewers
  • Next step: Review the latest changes.

This automated status or its linked feedback items may be incorrect. If something looks wrong, report it with the result you expected.

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

Adds stable semantic-convention batch-size telemetry for InfluxDB BatchPoints writes.

Changes:

  • Captures the number of points in batch writes.
  • Exposes it through InfluxDbAttributesGetter.
  • Verifies stable-semconv emission in the existing integration test.

Reviewed changes

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

File Description
InfluxDbOperation.java Stores the nullable batch size.
InfluxDbImplInstrumentation.java Extracts the BatchPoints point count.
InfluxDbAttributesGetter.java Supplies the batch size to database attribute extraction.
InfluxDbClientTest.java Asserts db.operation.batch.size = 2.

@bhuvan-somisetty

Copy link
Copy Markdown
Contributor Author

All checks are green now. @trask @laurit @jaydeluca @zeitlinger would any of you have some time to take a look? You've reviewed my last few PRs (#19154, #19088, #19078) so tagging you again, but happy to hear from anyone else too.

@trask

trask commented Jul 20, 2026

Copy link
Copy Markdown
Member

hi @bhuvan-somisetty! I'm not sure that this should be represented a batch operation, which is related to why I sent open-telemetry/semantic-conventions#3811, what do you think? thanks

@bhuvan-somisetty

bhuvan-somisetty commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@trask Good point, and that clarification in semantic-conventions#3811 makes it clear: a BatchPoints.write() call is really a single write operation that accepts multiple point operands, the same way MGET isn't a batch just because it takes multiple keys. It doesn't fit "two or more operations explicitly submitted as separate operations."

I've reverted the db.operation.batch.size change in this PR back to what it was before. Thanks for flagging it!

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.

influxdb-2.4: capture db.operation.batch.size for BatchPoints writes

3 participants