Skip to content

Commit a9e2669

Browse files
committed
rename to exclude
1 parent 872c429 commit a9e2669

File tree

4 files changed

+23
-27
lines changed

4 files changed

+23
-27
lines changed

sentry_sdk/consts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,7 @@ def __init__(
649649
trace_propagation_targets=[ # noqa: B006
650650
MATCH_ALL
651651
], # type: Optional[Sequence[str]]
652-
disabled_span_origins=None, # type: Optional[Sequence[str]]
652+
exclude_span_origins=None, # type: Optional[Sequence[str]]
653653
functions_to_trace=[], # type: Sequence[Dict[str, str]] # noqa: B006
654654
event_scrubber=None, # type: Optional[sentry_sdk.scrubber.EventScrubber]
655655
max_value_length=DEFAULT_MAX_VALUE_LENGTH, # type: int
@@ -981,11 +981,11 @@ def __init__(
981981
If `trace_propagation_targets` is not provided, trace data is attached to every outgoing request from the
982982
instrumented client.
983983
984-
:param disabled_span_origins: An optional list of strings or regex patterns to disable span creation based
984+
:param exclude_span_origins: An optional list of strings or regex patterns to exclude span creation based
985985
on span origin. When a span's origin would match any of the provided patterns, the span will not be
986986
created.
987987
988-
This can be useful to disable automatic span creation from specific integrations without disabling the
988+
This can be useful to exclude automatic span creation from specific integrations without disabling the
989989
entire integration.
990990
991991
The option may contain a list of strings or regexes against which the span origins are matched.

sentry_sdk/tracing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
)
4040
from sentry_sdk.tracing_utils import (
4141
get_span_status_from_http_code,
42-
is_span_origin_disabled,
42+
_is_span_origin_disabled,
4343
)
4444
from sentry_sdk.utils import (
4545
_serialize_span_attribute,
@@ -208,7 +208,7 @@ def __init__(
208208
not parent_span_context.is_valid or parent_span_context.is_remote
209209
)
210210

211-
if not skip_span and is_span_origin_disabled(origin):
211+
if not skip_span and _is_span_origin_disabled(origin):
212212
skip_span = True
213213

214214
if skip_span:

sentry_sdk/tracing_utils.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -689,20 +689,20 @@ def should_propagate_trace(client, url):
689689
return match_regex_list(url, trace_propagation_targets, substring_matching=True)
690690

691691

692-
def is_span_origin_disabled(origin):
692+
def _is_span_origin_disabled(origin):
693693
# type: (Optional[str]) -> bool
694694
"""
695-
Check if spans with this origin should be ignored.
695+
Check if spans with this origin should be ignored based on the `exclude_span_origins` option.
696696
"""
697697
if origin is None:
698698
return False
699699

700700
client = sentry_sdk.get_client()
701-
disabled_span_origins = client.options.get("disabled_span_origins")
702-
if not disabled_span_origins:
701+
exclude_span_origins = client.options.get("exclude_span_origins")
702+
if not exclude_span_origins:
703703
return False
704704

705-
return match_regex_list(origin, disabled_span_origins, substring_matching=True)
705+
return match_regex_list(origin, exclude_span_origins, substring_matching=True)
706706

707707

708708
def normalize_incoming_data(incoming_data):

tests/tracing/test_span_origin.py

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,11 @@ def test_span_origin_custom(sentry_init, capture_events):
3939
assert second_transaction["spans"][0]["origin"] == "baz.baz2.baz3"
4040

4141

42-
@pytest.mark.parametrize("disabled_origins", [None, [], "noop"])
43-
def test_disabled_span_origins_empty_config(
44-
sentry_init, capture_events, disabled_origins
45-
):
46-
"""Test that when disabled_span_origins is None or empty, all spans are allowed."""
47-
if disabled_origins in (None, []):
48-
sentry_init(traces_sample_rate=1.0, disabled_span_origins=disabled_origins)
49-
elif disabled_origins == "noop":
42+
@pytest.mark.parametrize("excluded_origins", [None, [], "noop"])
43+
def test_exclude_span_origins_empty(sentry_init, capture_events, excluded_origins):
44+
if excluded_origins in (None, []):
45+
sentry_init(traces_sample_rate=1.0, exclude_span_origins=excluded_origins)
46+
elif excluded_origins == "noop":
5047
sentry_init(
5148
traces_sample_rate=1.0,
5249
# default is None
@@ -65,7 +62,7 @@ def test_disabled_span_origins_empty_config(
6562

6663

6764
@pytest.mark.parametrize(
68-
"disabled_origins,origins,expected_events_count,expected_allowed_origins",
65+
"excluded_origins,origins,expected_events_count,expected_allowed_origins",
6966
[
7067
# Regexes
7168
(
@@ -105,18 +102,17 @@ def test_disabled_span_origins_empty_config(
105102
),
106103
],
107104
)
108-
def test_disabled_span_origins_filtering(
105+
def test_exclude_span_origins_patterns(
109106
sentry_init,
110107
capture_events,
111-
disabled_origins,
108+
excluded_origins,
112109
origins,
113110
expected_events_count,
114111
expected_allowed_origins,
115112
):
116-
"""Test disabled_span_origins with various pattern configurations."""
117113
sentry_init(
118114
traces_sample_rate=1.0,
119-
disabled_span_origins=disabled_origins,
115+
exclude_span_origins=excluded_origins,
120116
)
121117

122118
events = capture_events()
@@ -134,8 +130,8 @@ def test_disabled_span_origins_filtering(
134130
assert captured_origins == set(expected_allowed_origins)
135131

136132

137-
def test_disabled_span_origins_with_child_spans(sentry_init, capture_events):
138-
sentry_init(traces_sample_rate=1.0, disabled_span_origins=[r"auto\.http\..*"])
133+
def test_exclude_span_origins_with_child_spans(sentry_init, capture_events):
134+
sentry_init(traces_sample_rate=1.0, exclude_span_origins=[r"auto\.http\..*"])
139135
events = capture_events()
140136

141137
with start_span(name="parent", origin="manual"):
@@ -150,8 +146,8 @@ def test_disabled_span_origins_with_child_spans(sentry_init, capture_events):
150146
assert events[0]["spans"][0]["origin"] == "auto.db.postgres"
151147

152148

153-
def test_disabled_span_origin_parent_with_child_spans(sentry_init, capture_events):
154-
sentry_init(traces_sample_rate=1.0, disabled_span_origins=[r"auto\.http\..*"])
149+
def test_exclude_span_origins_parent_with_child_spans(sentry_init, capture_events):
150+
sentry_init(traces_sample_rate=1.0, exclude_span_origins=[r"auto\.http\..*"])
155151
events = capture_events()
156152

157153
with start_span(name="parent", origin="auto.http.requests"):

0 commit comments

Comments
 (0)