Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/5655.fixed
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
`opentelemetry-sdk`: add validation for export_timeout_millis <= 0 in PeriodicExportingMetricReader
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@ def _after_in_child() -> None:
f"interval value {self._export_interval_millis} is invalid \
and needs to be larger than zero."
)
if self._export_timeout_millis <= 0:
raise ValueError(
f"timeout value {self._export_timeout_millis} is invalid \
and needs to be larger than zero."
)

def _at_fork_reinit(self):
self._daemon_thread = Thread(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,26 @@ def test_ticker_value_exception_on_negative(self):
export_interval_millis=-100,
)

def test_timeout_value_exception_on_zero(self):
exporter = FakeMetricsExporter()
exporter.export = Mock()
self.assertRaises(
ValueError,
PeriodicExportingMetricReader,
exporter,
export_timeout_millis=0,
)

def test_timeout_value_exception_on_negative(self):
exporter = FakeMetricsExporter()
exporter.export = Mock()
self.assertRaises(
ValueError,
PeriodicExportingMetricReader,
exporter,
export_timeout_millis=-100,
)

@pytest.mark.flaky(max_runs=3, min_passes=1)
def test_ticker_collects_metrics(self):
exporter = FakeMetricsExporter()
Expand Down