diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index 9ea2d9859a..a1cfd729c2 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -638,6 +638,10 @@ def strip_sentry_baggage(header): ) ) + def __repr__(self): + # type: () -> str + return f'' + def should_propagate_trace(client, url): # type: (sentry_sdk.client.BaseClient, str) -> bool diff --git a/tests/test_tracing_utils.py b/tests/test_tracing_utils.py index 5c1f70516d..2b2c62a6f9 100644 --- a/tests/test_tracing_utils.py +++ b/tests/test_tracing_utils.py @@ -115,3 +115,34 @@ def test_should_be_included(test_case, expected): ) def test_strip_sentry_baggage(header, expected): assert Baggage.strip_sentry_baggage(header) == expected + + +@pytest.mark.parametrize( + ("baggage", "expected_repr"), + ( + (Baggage(sentry_items={}), ''), + (Baggage(sentry_items={}, mutable=False), ''), + ( + Baggage(sentry_items={"foo": "bar"}), + '', + ), + ( + Baggage(sentry_items={"foo": "bar"}, mutable=False), + '', + ), + ( + Baggage(sentry_items={"foo": "bar"}, third_party_items="asdf=1234,"), + '', + ), + ( + Baggage( + sentry_items={"foo": "bar"}, + third_party_items="asdf=1234,", + mutable=False, + ), + '', + ), + ), +) +def test_baggage_repr(baggage, expected_repr): + assert repr(baggage) == expected_repr