From 0f0c335c312b1cad3b245c477af95cf8f2c71cf3 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Fri, 24 Jul 2026 13:38:18 +0200 Subject: [PATCH] test: Add streaming metrics test --- tests/test_metrics.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/test_metrics.py b/tests/test_metrics.py index 23e11f0135..ccff2353d9 100644 --- a/tests/test_metrics.py +++ b/tests/test_metrics.py @@ -146,6 +146,23 @@ def test_metrics_with_span(sentry_init, capture_items): assert metrics[0]["span_id"] == transaction.span_id +def test_metrics_with_span_span_streaming(sentry_init, capture_items): + sentry_init(traces_sample_rate=1.0, trace_lifecycle="stream") + items = capture_items("trace_metric") + + with sentry_sdk.traces.start_span(name="test-span") as segment: + sentry_sdk.metrics.count("test.span.counter", 1) + + sentry_sdk.flush() + + metrics = [item.payload for item in items] + assert len(metrics) == 1 + + assert metrics[0]["trace_id"] is not None + assert metrics[0]["trace_id"] == segment.trace_id + assert metrics[0]["span_id"] == segment.span_id + + def test_metrics_tracing_without_performance(sentry_init, capture_items): sentry_init() items = capture_items("trace_metric")