|
9 | 9 | from tests.conftest import patch_start_tracing_child
|
10 | 10 |
|
11 | 11 | import sentry_sdk
|
| 12 | +import sentry_sdk.scope |
12 | 13 | from sentry_sdk import (
|
13 | 14 | push_scope,
|
14 | 15 | configure_scope,
|
|
29 | 30 | )
|
30 | 31 | from sentry_sdk.integrations.logging import LoggingIntegration
|
31 | 32 | from sentry_sdk.integrations.redis import RedisIntegration
|
32 |
| -from sentry_sdk.scope import ( # noqa: F401 |
33 |
| - add_global_event_processor, |
34 |
| - global_event_processors, |
35 |
| -) |
| 33 | +from sentry_sdk.scope import add_global_event_processor |
36 | 34 | from sentry_sdk.utils import get_sdk_name, reraise
|
37 | 35 | from sentry_sdk.tracing_utils import has_tracing_enabled
|
38 | 36 |
|
@@ -581,21 +579,31 @@ def test_event_processor_drop_records_client_report(
|
581 | 579 | events = capture_events()
|
582 | 580 | reports = capture_client_reports()
|
583 | 581 |
|
584 |
| - global global_event_processors |
| 582 | + # Ensure full idempotency by restoring the original global event processors list object, not just a copy. |
| 583 | + old_processors = sentry_sdk.scope.global_event_processors |
585 | 584 |
|
586 |
| - @add_global_event_processor |
587 |
| - def foo(event, hint): |
588 |
| - return None |
| 585 | + try: |
| 586 | + sentry_sdk.scope.global_event_processors = ( |
| 587 | + sentry_sdk.scope.global_event_processors.copy() |
| 588 | + ) |
589 | 589 |
|
590 |
| - capture_message("dropped") |
| 590 | + @add_global_event_processor |
| 591 | + def foo(event, hint): |
| 592 | + return None |
591 | 593 |
|
592 |
| - with start_transaction(name="dropped"): |
593 |
| - pass |
| 594 | + capture_message("dropped") |
594 | 595 |
|
595 |
| - assert len(events) == 0 |
596 |
| - assert reports == [("event_processor", "error"), ("event_processor", "transaction")] |
| 596 | + with start_transaction(name="dropped"): |
| 597 | + pass |
| 598 | + |
| 599 | + assert len(events) == 0 |
| 600 | + assert reports == [ |
| 601 | + ("event_processor", "error"), |
| 602 | + ("event_processor", "transaction"), |
| 603 | + ] |
597 | 604 |
|
598 |
| - global_event_processors.pop() |
| 605 | + finally: |
| 606 | + sentry_sdk.scope.global_event_processors = old_processors |
599 | 607 |
|
600 | 608 |
|
601 | 609 | @pytest.mark.parametrize(
|
|
0 commit comments