Skip to content

Commit 894391e

Browse files
committed
test
1 parent 554e6cf commit 894391e

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

tests/test_attributes.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
from tests.test_metrics import envelopes_to_metrics
44

55

6+
def test_top_level_api(sentry_init, capture_envelopes):
7+
sentry_init()
8+
9+
envelopes = capture_envelopes()
10+
11+
sentry_sdk.set_attribute("set", "value")
12+
sentry_sdk.set_attribute("remove", "value")
13+
sentry_sdk.remove_attribute("removed", "value")
14+
# Attempting to remove a nonexistent attribute should not raise
15+
sentry_sdk.remove_attribute("nonexistent", "value")
16+
17+
sentry_sdk.metrics.count("test", 1)
18+
sentry_sdk.get_client().flush()
19+
20+
metrics = envelopes_to_metrics(envelopes)
21+
(metric,) = metrics
22+
23+
assert metric["attributes"]["set"] == "value"
24+
assert "remove" not in metric["attributes"]
25+
26+
627
def test_scope_precedence(sentry_init, capture_envelopes):
728
# Order of precedence, from most important to least:
829
# 1. telemetry attributes (directly supplying attributes on creation or using set_attribute)

0 commit comments

Comments
 (0)