Skip to content

Create BatchSpanProcessorBurstBenchmark.java - #8911

Open
adhamahmad wants to merge 3 commits into
open-telemetry:mainfrom
adhamahmad:add-batch-span-processor-burst-bench-mark
Open

adhamahmad wants to merge 3 commits into
open-telemetry:mainfrom
adhamahmad:add-batch-span-processor-burst-bench-mark

Conversation

@adhamahmad

Copy link
Copy Markdown
Contributor

Add JMH benchmark for BatchSpanProcessor burst absorption

Description

Part of #7508.

Follows the approach agreed in the issue: "Add a benchmark/test scenario that reproduces bursty high-throughput conditions and reports span drop behavior consistently" (agreed by @jack-berg).

Benchmark only: no production code or defaults change. It is a baseline for comparing opt-in alternatives later.

Changes

  • Add BatchSpanProcessorBurstBenchmark. Each operation produces a burst (6,000 spans) and calls forceFlush(); to ensure the accepted spans are fully processed before the next burst.
  • Simulate export latency (default 50 ms) with an exporter that completes asynchronously.
  • Parameterize burst size, maxQueueSize, maxExportBatchSize and exporter latency.
  • Report producedSpans, exportedSpans and droppedSpans as aux counters, updated during the measured operation. Drops come from the processor's internal telemetry (BatchSpanProcessorMetrics) and are checked against what the exporter completed; the benchmark fails if they disagree.

Testing

.\gradlew.bat --no-configuration-cache -PjmhIncludeSingleClass=BatchSpanProcessorBurstBenchmark :sdk:trace:jmh
.\gradlew.bat :sdk:trace:compileJmhJava :sdk:trace:checkstyleJmh

Per 6,000-span burst (aux counters are per-iteration totals, divided by bursts):

maxQueueSize Exported Dropped Time per burst
2048 (default) 2,560 3,440 (57%) ~293 ms
8192 6,000 0 ~672 ms

With the default queue, 57% of the burst is dropped. Increasing the queue to 8192 eliminates the drops for this workload, but requires draining all 6,000 spans rather than the 2,560 spans accepted with the default queue.

Environment: Windows, Temurin JDK 21.0.10. Absolute times are platform-dependent.

@adhamahmad
adhamahmad requested a review from a team as a code owner October 6, 2026 23:35
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on the author · refreshed 2026-11-21 01:36 UTC

Two things need attention:

  • Required checks are failing — investigate the failures.
  • 1 review item — respond to each (e.g. link a commit, explain why not, ask a follow-up):
    • Top-level threads: 1
Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with reviewers? Comment /dashboard route:reviewers to route it to them.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.45%. Comparing base (f0549eb) to head (cfe9a2c).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #8911   +/-   ##
=========================================
  Coverage     90.45%   90.45%           
- Complexity    11182    11183    +1     
=========================================
  Files          1032     1032           
  Lines         30508    30508           
  Branches       3992     3992           
=========================================
+ Hits          27596    27597    +1     
  Misses         1935     1935           
+ Partials        977      976    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@adhamahmad

Copy link
Copy Markdown
Contributor Author

Hey @jack-berg , Appreciate any feedback on this.

@jack-berg jack-berg left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you interested in following this up with work to try to improve things around this benchmark? If so, what is your plan?

Its not useful to land a benchmark unless we're going to use it as a way to measure optimization progress.

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Hi @adhamahmad — just a friendly reminder that this pull request is waiting on you. The dashboard status comment has the open items and is kept current.

  • Replying is enough to hand it off — answer, explain why no change is needed, or ask a follow-up. The dashboard routes it onward once nothing on the list is waiting on you.
  • To hand it back for any other reason, including the dashboard getting this wrong, comment /dashboard route:reviewers.

@adhamahmad

Copy link
Copy Markdown
Contributor Author

Are you interested in following this up with work to try to improve things around this benchmark? If so, what is your plan?

Hey @jack-berg , thanks for the review and sorry for the delay.

Yes, I’m interested in following this up. The plan:

  1. Use this benchmark as the baseline for Optimize data loss issues for high-resource single-instance deployments that generate a large number of spans. #7508 and measure what existing config (maxExportBatchSize, maxQueueSize) already achieves.

  2. Prototype an opt-in export path that allows multiple in-flight exports (as a separate processor or a builder option, whichever you prefer), using the drop fraction from this benchmark as the success metric.

  3. Post the before and after numbers , so we have a clearer picture of how to move forward.

I'll work through all your comments on the benchmark over the next few days.

@adhamahmad
adhamahmad force-pushed the add-batch-span-processor-burst-bench-mark branch from b34e6c9 to 1866bc9 Compare November 21, 2026 00:47
@adhamahmad
adhamahmad requested a review from jack-berg November 21, 2026 01:35

This branch has not been deployed

No deployments
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