Skip to content

Support PeriodicMetricReader export timeout in autoconfigure and declarative config - #9090

Open
adityad171 wants to merge 1 commit into
open-telemetry:mainfrom
adityad171:fix/periodic-reader-export-timeout-config
Open

adityad171 wants to merge 1 commit into
open-telemetry:mainfrom
adityad171:fix/periodic-reader-export-timeout-config

Conversation

@adityad171

@adityad171 adityad171 commented Dec 2, 2026 •

Copy link
Copy Markdown

Fixes #9089

PeriodicMetricReaderBuilder#setExporterTimeout (#8827) could not be set from config. This applies it in both config paths:

  • autoconfigure: otel.metric.export.timeout / OTEL_METRIC_EXPORT_TIMEOUT
  • declarative config: meter_provider.readers[].periodic.timeout

Both work like otel.bsp.export.timeout and the batch processors' export_timeout: the value is used only when it is set, and 0 means no limit. When it is not set, the reader keeps the export interval as its timeout, so nothing changes for users who don't set it.

PeriodicMetricReader#toString now includes exporterTimeoutNanos, like BatchSpanProcessor. MetricReaderFactoryTest compares readers by toString, which is why the dropped value was not caught.

Things to note:

  • Users who already set OTEL_METRIC_EXPORT_TIMEOUT (for example for other SDKs), or periodic.timeout in a declarative config file, will now get that timeout. Today Java ignores both.
  • A negative value fails autoconfigure, as otel.bsp.export.timeout does. The spec says it MUST be ignored with a warning; I kept the existing Java behaviour to stay consistent.
  • The spec default is 30000 ms. I kept the interval default from Refator PMR to use dedicated thread and add export timeout setting #8827. Happy to change it.

Testing: with the config changes reverted, MetricExporterConfigurationTest (_configured, _zeroExporterTimeout) and MetricReaderFactoryTest ("periodic configured") fail.

Parts of this change were written with an AI coding assistant; I reviewed and tested all of it.

…arative config

PeriodicMetricReaderBuilder#setExporterTimeout was added in open-telemetry#8827, but no
config path calls it. Declarative config parses periodic.timeout and drops
it, and autoconfigure does not read the spec-defined
otel.metric.export.timeout (OTEL_METRIC_EXPORT_TIMEOUT).

Apply the timeout in both paths when it is set. When it is not set, the
reader keeps the open-telemetry#8827 default (the export interval). Also print
exporterTimeoutNanos in PeriodicMetricReader#toString, as the batch
processors do, so the toString-based factory test can see it.
@adityad171
adityad171 requested a review from a team as a code owner December 2, 2026 13:54
@codecov

codecov Bot commented Dec 2, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.53%. Comparing base (e91fe6d) to head (9479ff5).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #9090      +/-   ##
============================================
- Coverage     90.54%   90.53%   -0.01%     
- Complexity    11254    11256       +2     
============================================
  Files          1040     1040              
  Lines         30703    30708       +5     
  Branches       4015     4017       +2     
============================================
+ Hits          27799    27803       +4     
  Misses         1928     1928              
- Partials        976      977       +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.

@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-12-02 15:10 UTC

Review the latest changes.

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 the author? Comment /dashboard route:author to route it back.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

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.

PeriodicMetricReader export timeout is ignored by autoconfigure and declarative config

1 participant