1
+ from unittest import mock
1
2
import pytest
2
3
3
4
from string import Template
@@ -66,7 +67,9 @@ def record(self, span_id: int):
66
67
def test_on_new_span_on_close (sentry_init , capture_events ):
67
68
rust_tracing = FakeRustTracing ()
68
69
integration = RustTracingIntegration (
69
- "test_on_new_span_on_close" , rust_tracing .set_layer_impl
70
+ "test_on_new_span_on_close" ,
71
+ initializer = rust_tracing .set_layer_impl ,
72
+ include_tracing_fields = True ,
70
73
)
71
74
sentry_init (integrations = [integration ], traces_sample_rate = 1.0 )
72
75
@@ -105,7 +108,9 @@ def test_on_new_span_on_close(sentry_init, capture_events):
105
108
def test_nested_on_new_span_on_close (sentry_init , capture_events ):
106
109
rust_tracing = FakeRustTracing ()
107
110
integration = RustTracingIntegration (
108
- "test_nested_on_new_span_on_close" , rust_tracing .set_layer_impl
111
+ "test_nested_on_new_span_on_close" ,
112
+ initializer = rust_tracing .set_layer_impl ,
113
+ include_tracing_fields = True ,
109
114
)
110
115
sentry_init (integrations = [integration ], traces_sample_rate = 1.0 )
111
116
@@ -331,7 +336,10 @@ def span_filter(metadata: Dict[str, object]) -> bool:
331
336
332
337
rust_tracing = FakeRustTracing ()
333
338
integration = RustTracingIntegration (
334
- "test_span_filter" , rust_tracing .set_layer_impl , span_filter = span_filter
339
+ "test_span_filter" ,
340
+ initializer = rust_tracing .set_layer_impl ,
341
+ span_filter = span_filter ,
342
+ include_tracing_fields = True ,
335
343
)
336
344
sentry_init (integrations = [integration ], traces_sample_rate = 1.0 )
337
345
@@ -365,7 +373,7 @@ def test_record(sentry_init):
365
373
integration = RustTracingIntegration (
366
374
"test_record" ,
367
375
initializer = rust_tracing .set_layer_impl ,
368
- send_sensitive_data = True ,
376
+ include_tracing_fields = True ,
369
377
)
370
378
sentry_init (integrations = [integration ], traces_sample_rate = 1.0 )
371
379
@@ -391,6 +399,7 @@ def span_filter(metadata: Dict[str, object]) -> bool:
391
399
"test_record_in_ignored_span" ,
392
400
rust_tracing .set_layer_impl ,
393
401
span_filter = span_filter ,
402
+ include_tracing_fields = True ,
394
403
)
395
404
sentry_init (integrations = [integration ], traces_sample_rate = 1.0 )
396
405
@@ -409,7 +418,7 @@ def span_filter(metadata: Dict[str, object]) -> bool:
409
418
410
419
411
420
@pytest .mark .parametrize (
412
- "send_default_pii, send_sensitive_data, sensitive_data_expected " ,
421
+ "send_default_pii, include_tracing_fields, tracing_fields_expected " ,
413
422
[
414
423
(True , True , True ),
415
424
(True , False , False ),
@@ -419,14 +428,14 @@ def span_filter(metadata: Dict[str, object]) -> bool:
419
428
(False , None , False ),
420
429
],
421
430
)
422
- def test_sensitive_data (
423
- sentry_init , send_default_pii , send_sensitive_data , sensitive_data_expected
431
+ def test_include_tracing_fields (
432
+ sentry_init , send_default_pii , include_tracing_fields , tracing_fields_expected
424
433
):
425
434
rust_tracing = FakeRustTracing ()
426
435
integration = RustTracingIntegration (
427
436
"test_record" ,
428
437
initializer = rust_tracing .set_layer_impl ,
429
- send_sensitive_data = send_sensitive_data ,
438
+ include_tracing_fields = include_tracing_fields ,
430
439
)
431
440
432
441
sentry_init (
@@ -438,13 +447,29 @@ def test_sensitive_data(
438
447
rust_tracing .new_span (RustTracingLevel .Info , 3 )
439
448
440
449
span_before_record = sentry_sdk .get_current_span ().to_json ()
441
- assert span_before_record ["data" ]["version" ] is None
450
+ if tracing_fields_expected :
451
+ assert span_before_record ["data" ]["version" ] is None
452
+ else :
453
+ assert span_before_record ["data" ]["version" ] == "[Filtered]"
442
454
443
455
rust_tracing .record (3 )
444
456
445
457
span_after_record = sentry_sdk .get_current_span ().to_json ()
446
458
447
- if sensitive_data_expected :
448
- assert span_after_record ["data" ]["version" ] == "memoized"
459
+ if tracing_fields_expected :
460
+ assert span_after_record ["data" ] == {
461
+ "thread.id" : mock .ANY ,
462
+ "thread.name" : mock .ANY ,
463
+ "use_memoized" : True ,
464
+ "version" : "memoized" ,
465
+ "index" : 10 ,
466
+ }
467
+
449
468
else :
450
- assert span_after_record ["data" ]["version" ] == "[Filtered]"
469
+ assert span_after_record ["data" ] == {
470
+ "thread.id" : mock .ANY ,
471
+ "thread.name" : mock .ANY ,
472
+ "use_memoized" : "[Filtered]" ,
473
+ "version" : "[Filtered]" ,
474
+ "index" : "[Filtered]" ,
475
+ }
0 commit comments