Skip to content

Commit abedeaa

Browse files
committed
add case to ignore_spans tests
1 parent 0518f56 commit abedeaa

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

sentry_sdk/tracing_utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1483,7 +1483,11 @@ def is_ignored_span(name: str, attributes: "Optional[Attributes]") -> bool:
14831483

14841484
def _matches(rule: "Any", value: "Any") -> bool:
14851485
if isinstance(rule, Pattern):
1486-
return bool(rule.match(value))
1486+
if isinstance(value, str):
1487+
return bool(rule.match(value))
1488+
else:
1489+
return False
1490+
14871491
return rule == value
14881492

14891493
for rule in ignore_spans:

tests/tracing/test_span_streaming.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -851,6 +851,7 @@ def test_set_span_origin(sentry_init, capture_envelopes):
851851
@pytest.mark.parametrize(
852852
("ignore_spans", "name", "attributes", "ignored"),
853853
[
854+
# no regexes
854855
([], "/health", {}, False),
855856
(["/health"], "/health", {}, True),
856857
(["/health"], "/health", {"custom": "custom"}, True),
@@ -876,6 +877,7 @@ def test_set_span_origin(sentry_init, capture_envelopes):
876877
{"custom": "custom"},
877878
True,
878879
),
880+
# test cases with regexes
879881
([re.compile("/hea.*")], "/health", {}, True),
880882
([re.compile("/hea.*")], "/health", {"custom": "custom"}, True),
881883
([{"name": re.compile("/hea.*")}], "/health", {}, True),
@@ -920,6 +922,12 @@ def test_set_span_origin(sentry_init, capture_envelopes):
920922
{"custom": "custom"},
921923
True,
922924
),
925+
(
926+
[{"attributes": {"listattr": re.compile(r"\[.*\]")}}],
927+
"/a",
928+
{"listattr": [1, 2, 3]},
929+
False,
930+
),
923931
],
924932
)
925933
def test_ignore_spans(

0 commit comments

Comments
 (0)