Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sdk: make test_batch_span_processor_scheduled_delay a bit more robust #3938

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,13 @@ def _ticker(self) -> None:
exc_info=True,
)
# one last collection below before shutting down completely
self.collect(timeout_millis=self._export_interval_millis)
try:
self.collect(timeout_millis=self._export_interval_millis)
except MetricsTimeoutError:
_logger.warning(
"Metric collection timed out.",
exc_info=True,
)

def _receive_metrics(
self,
Expand Down
6 changes: 5 additions & 1 deletion opentelemetry-sdk/tests/trace/export/test_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,10 @@ def _target():

span_processor.shutdown()

@mark.skipif(
python_implementation() == "PyPy" and system() == "Windows",
reason="This test randomly fails with huge delta in Windows with PyPy",
)
def test_batch_span_processor_scheduled_delay(self):
"""Test that spans are exported each schedule_delay_millis"""
spans_names_list = []
Expand All @@ -482,7 +486,7 @@ def test_batch_span_processor_scheduled_delay(self):
self.assertTrue(export_event.wait(2))
export_time = time.time()
self.assertEqual(len(spans_names_list), 1)
self.assertGreaterEqual((export_time - start_time) * 1e3, 500)
self.assertAlmostEqual((export_time - start_time) * 1e3, 500, delta=25)

span_processor.shutdown()

Expand Down