Skip to content

Commit c8ade94

Browse files
committed
fix: remove inconsistent PII filtering from rust_tracing integration
1 parent 4bec4a4 commit c8ade94

File tree

2 files changed

+2
-63
lines changed

2 files changed

+2
-63
lines changed

sentry_sdk/integrations/rust_tracing.py

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@
3636

3737
import sentry_sdk
3838
from sentry_sdk.integrations import Integration
39-
from sentry_sdk.scope import should_send_default_pii
4039
from sentry_sdk.tracing import Span as SentrySpan
41-
from sentry_sdk.utils import SENSITIVE_DATA_SUBSTITUTE
4240

4341
TraceState = Optional[Tuple[Optional[SentrySpan], SentrySpan]]
4442

@@ -151,12 +149,10 @@ def __init__(
151149
[Dict[str, Any]], EventTypeMapping
152150
] = default_event_type_mapping,
153151
span_filter: Callable[[Dict[str, Any]], bool] = default_span_filter,
154-
send_sensitive_data: Optional[bool] = None,
155152
):
156153
self.origin = origin
157154
self.event_type_mapping = event_type_mapping
158155
self.span_filter = span_filter
159-
self.send_sensitive_data = send_sensitive_data
160156

161157
def on_event(self, event: str, _span_state: TraceState) -> None:
162158
deserialized_event = json.loads(event)
@@ -225,18 +221,9 @@ def on_record(self, span_id: str, values: str, span_state: TraceState) -> None:
225221
return
226222
_parent_sentry_span, sentry_span = span_state
227223

228-
send_sensitive_data = (
229-
should_send_default_pii()
230-
if self.send_sensitive_data is None
231-
else self.send_sensitive_data
232-
)
233-
234224
deserialized_values = json.loads(values)
235225
for key, value in deserialized_values.items():
236-
if send_sensitive_data:
237-
sentry_span.set_data(key, value)
238-
else:
239-
sentry_span.set_data(key, SENSITIVE_DATA_SUBSTITUTE)
226+
sentry_span.set_data(key, value)
240227

241228

242229
class RustTracingIntegration(Integration):
@@ -259,13 +246,10 @@ def __init__(
259246
[Dict[str, Any]], EventTypeMapping
260247
] = default_event_type_mapping,
261248
span_filter: Callable[[Dict[str, Any]], bool] = default_span_filter,
262-
send_sensitive_data: Optional[bool] = None,
263249
):
264250
self.identifier = identifier
265251
origin = f"auto.function.rust_tracing.{identifier}"
266-
self.tracing_layer = RustTracingLayer(
267-
origin, event_type_mapping, span_filter, send_sensitive_data
268-
)
252+
self.tracing_layer = RustTracingLayer(origin, event_type_mapping, span_filter)
269253

270254
initializer(self.tracing_layer)
271255

tests/integrations/rust_tracing/test_rust_tracing.py

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import pytest
2-
31
from string import Template
42
from typing import Dict
53

@@ -365,7 +363,6 @@ def test_record(sentry_init):
365363
integration = RustTracingIntegration(
366364
"test_record",
367365
initializer=rust_tracing.set_layer_impl,
368-
send_sensitive_data=True,
369366
)
370367
sentry_init(integrations=[integration], traces_sample_rate=1.0)
371368

@@ -406,45 +403,3 @@ def span_filter(metadata: Dict[str, object]) -> bool:
406403
# `on_record()` should not do anything to the current Sentry span if the associated Rust span was ignored
407404
span_after_record = sentry_sdk.get_current_span().to_json()
408405
assert span_after_record["data"]["version"] is None
409-
410-
411-
@pytest.mark.parametrize(
412-
"send_default_pii, send_sensitive_data, sensitive_data_expected",
413-
[
414-
(True, True, True),
415-
(True, False, False),
416-
(True, None, True),
417-
(False, True, True),
418-
(False, False, False),
419-
(False, None, False),
420-
],
421-
)
422-
def test_sensitive_data(
423-
sentry_init, send_default_pii, send_sensitive_data, sensitive_data_expected
424-
):
425-
rust_tracing = FakeRustTracing()
426-
integration = RustTracingIntegration(
427-
"test_record",
428-
initializer=rust_tracing.set_layer_impl,
429-
send_sensitive_data=send_sensitive_data,
430-
)
431-
432-
sentry_init(
433-
integrations=[integration],
434-
traces_sample_rate=1.0,
435-
send_default_pii=send_default_pii,
436-
)
437-
with start_transaction():
438-
rust_tracing.new_span(RustTracingLevel.Info, 3)
439-
440-
span_before_record = sentry_sdk.get_current_span().to_json()
441-
assert span_before_record["data"]["version"] is None
442-
443-
rust_tracing.record(3)
444-
445-
span_after_record = sentry_sdk.get_current_span().to_json()
446-
447-
if sensitive_data_expected:
448-
assert span_after_record["data"]["version"] == "memoized"
449-
else:
450-
assert span_after_record["data"]["version"] == "[Filtered]"

0 commit comments

Comments
 (0)