Skip to content

Add support for batching in PeriodicMetricReader#8296

Open
psx95 wants to merge 55 commits intoopen-telemetry:mainfrom
psx95:issue-8245
Open

Add support for batching in PeriodicMetricReader#8296
psx95 wants to merge 55 commits intoopen-telemetry:mainfrom
psx95:issue-8245

Conversation

@psx95
Copy link
Copy Markdown
Contributor

@psx95 psx95 commented Apr 15, 2026

This PR adds support for configuring setMaxExportBatchSize on the PeriodicMetricReader that sets the maximum number of metric data points to be sent in a single export call.

If the number of metric data points (across Collection<MetricData>) scheduled to be export exceeds the maxExportBatchSize, the data points organized in batches and sent over multiple export calls.

These changes do not modify the current timeout behavior, which is still per export call.

Fix #8245

@otelbot otelbot Bot added the api-change Changes to public API surface area label Apr 15, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 90.84507% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 90.82%. Comparing base (b87fa99) to head (b6edfb7).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...try/sdk/metrics/internal/SdkMeterProviderUtil.java 0.00% 8 Missing ⚠️
...emetry/sdk/metrics/export/MetricExportBatcher.java 96.93% 1 Missing and 2 partials ⚠️
...metry/sdk/metrics/export/PeriodicMetricReader.java 93.75% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8296      +/-   ##
============================================
- Coverage     90.82%   90.82%   -0.01%     
- Complexity     7927     7944      +17     
============================================
  Files           895      896       +1     
  Lines         23872    24010     +138     
  Branches       2378     2390      +12     
============================================
+ Hits          21681    21806     +125     
- Misses         1446     1456      +10     
- Partials        745      748       +3     

☔ View full report in Codecov by Sentry.
📢 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.

@psx95 psx95 marked this pull request as ready for review April 15, 2026 18:42
@psx95 psx95 requested a review from a team as a code owner April 15, 2026 18:42

This comment was marked as outdated.

Copy link
Copy Markdown

Copilot AI left a comment

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

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


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

zeitlinger and others added 5 commits April 27, 2026 07:49
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
# Conflicts:
#	sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/export/MetricExportBatcher.java
…ropagation' into lane-a-pr-8296

# Conflicts:
#	sdk/metrics/src/test/java/io/opentelemetry/sdk/metrics/export/PeriodicMetricReaderTest.java
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
Signed-off-by: Gregor Zeitlinger <gregor.zeitlinger@grafana.com>
…propagation

Fix batched forceFlush failure and make batching linear
Copy link
Copy Markdown
Member

@jack-berg jack-berg left a comment

Choose a reason for hiding this comment

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

Couple of comments, but looks pretty good!

@otelbot otelbot Bot removed the api-change Changes to public API surface area label Apr 30, 2026
@psx95
Copy link
Copy Markdown
Contributor Author

psx95 commented May 1, 2026

Addressed all the feedback on this PR and added a Changelog entry as well.

The CI Build failure on Windows for Java 11 looks like a transient error and might be fixed upon retrying.

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.

Implement PeriodicMetricREader#maxExportBatchSize

5 participants