Skip to content

fix(sdk): add validation for export_timeout_millis <= 0 in PeriodicExportingMetricReader - #5656

Open
Dotify71 wants to merge 2 commits into
open-telemetry:mainfrom
Dotify71:fix-periodic-metric-reader-timeout-validation
Open

Dotify71 wants to merge 2 commits into
open-telemetry:mainfrom
Dotify71:fix-periodic-metric-reader-timeout-validation

Conversation

@Dotify71

Copy link
Copy Markdown

Description

Fixes #5655

Currently, PeriodicExportingMetricReader validates export_interval_millis during initialization and raises a ValueError if export_interval_millis <= 0. However, export_timeout_millis lacked validation for values <= 0, allowing non-positive integers (0 or negative values) to be passed without error.

Since _ticker() continuously calls self.collect(timeout_millis=self._export_timeout_millis), passing an unvalidated non-positive timeout causes collection timeout errors on every tick cycle.

This PR adds validation for export_timeout_millis <= 0 in PeriodicExportingMetricReader.__init__().

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Unit tests in opentelemetry-sdk/tests/metrics/test_periodic_exporting_metric_reader.py (test_timeout_value_exception_on_zero, test_timeout_value_exception_on_negative).

Does This PR Require a Contrib Repo Change?

  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@Dotify71
Dotify71 requested a review from a team as a code owner September 13, 2026 04:07
@opentelemetry-pr-dashboard

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-13 22:38 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.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@Dotify71

Copy link
Copy Markdown
Author

@lzchen This pr is ready for review

@herin049 herin049 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.

Thanks for the PR, if you have future small changes like these, please group them into a single PR.

@Dotify71

Copy link
Copy Markdown
Author

Thanks for the review and approval @herin049 I'll definitely group related small fixes into a single PR next time :))

@Shriprasad-P Shriprasad-P left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Nice focused PR. Please make sure docs/changelog stay aligned if the repo requires it for this kind of change.

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.

[bug] PeriodicExportingMetricReader missing validation for export_timeout_millis <= 0

3 participants