Skip to content

Commit 42058ea

Browse files
committed
fixes
1 parent 0420e0e commit 42058ea

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

sentry_sdk/traces.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
try_autostart_continuous_profiler,
2222
try_profile_lifecycle_trace_start,
2323
)
24-
from sentry_sdk.scope import should_send_default_pii
2524
from sentry_sdk.tracing_utils import Baggage
2625
from sentry_sdk.utils import (
2726
capture_internal_exceptions,
@@ -557,6 +556,8 @@ def _start_profile(self) -> None:
557556
self._continuous_profile = try_profile_lifecycle_trace_start()
558557

559558
def _set_segment_attributes(self) -> None:
559+
from sentry_sdk.scope import should_send_default_pii
560+
560561
if not self._is_segment():
561562
return
562563

tests/tracing/test_span_streaming.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,11 +1504,13 @@ def test_profile_stops_when_segment_ends(
15041504
assert get_profiler_id() is None, "profiler should have stopped"
15051505

15061506

1507-
def test_default_attributes(sentry_init, capture_envelopes):
1507+
@pytest.mark.parametrize("send_default_pii", [True, False])
1508+
def test_default_attributes(sentry_init, capture_envelopes, send_default_pii):
15081509
sentry_init(
15091510
server_name="test-server",
15101511
release="1.0.0",
15111512
traces_sample_rate=1.0,
1513+
send_default_pii=send_default_pii,
15121514
_experiments={"trace_lifecycle": "stream"},
15131515
)
15141516

@@ -1529,10 +1531,10 @@ def test_default_attributes(sentry_init, capture_envelopes):
15291531
"item_count": 1,
15301532
"content_type": "application/vnd.sentry.items.span.v2+json",
15311533
}
1532-
assert item.payload.json["items"][0]["attributes"] == {
1534+
1535+
expected_attributes = {
15331536
"thread.id": {"value": mock.ANY, "type": "string"},
15341537
"thread.name": {"value": "MainThread", "type": "string"},
1535-
"process.command_args": {"value": mock.ANY, "type": "array"},
15361538
"sentry.segment.id": {"value": mock.ANY, "type": "string"},
15371539
"sentry.segment.name": {"value": "test", "type": "string"},
15381540
"sentry.sdk.name": {"value": "sentry.python", "type": "string"},
@@ -1542,6 +1544,12 @@ def test_default_attributes(sentry_init, capture_envelopes):
15421544
"sentry.release": {"value": "1.0.0", "type": "string"},
15431545
"sentry.origin": {"value": "manual", "type": "string"},
15441546
}
1547+
if send_default_pii is True:
1548+
expected_attributes |= {
1549+
"process.command_args": {"value": mock.ANY, "type": "array"}
1550+
}
1551+
1552+
assert item.payload.json["items"][0]["attributes"] == expected_attributes
15451553

15461554

15471555
def test_transport_format(sentry_init, capture_envelopes):

0 commit comments

Comments
 (0)