8000 benchmark · SingleTM/sentry-python@5daed20 · GitHub
[go: up one dir, main page]

Skip to content

Commit 5daed20

Browse files
committed
benchmark
1 parent 2e0e4fd commit 5daed20

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

tests/test_tracing.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,28 @@
1414

1515

1616
@pytest.mark.parametrize("sample_rate", [0.0, 1.0])
17-
def test_basic(sentry_init, capture_events, sample_rate):
17+
@pytest.mark.parametrize("num_spans", [1, 900])
18+
def test_basic(sentry_init, capture_events, sample_rate, num_spans, benchmark):
1819
sentry_init(traces_sample_rate=sample_rate)
1920
events = capture_events()
2021

21-
with start_transaction(name="hi") as transaction:
22-
transaction.set_status("ok")
23-
with pytest.raises(ZeroDivisionError):
24-
with start_span(op="foo", description="foodesc"):
25-
1 / 0
22+
@benchmark
23+
def run():
24+
with start_transaction(name="hi") as transaction:
25+
transaction.set_status("ok")
26+
with pytest.raises(ZeroDivisionError):
27+
with start_span(op="foo", description="foodesc"):
28+
1 / 0
2629

27-
with start_span(op="bar", description="bardesc"):
28-
pass
30+
for _ in range(num_spans):
31+
with start_span(op="bar", description="bardesc"):
32+
pass
2933

3034
if sample_rate:
31-
assert len(events) == 1
3235
event = events[0]
3336

34-
span1, span2 = event["spans"]
37+
assert len(event['spans']) == num_spans + 1
38+
span1, span2 = event["spans"][:2]
3539
parent_span = event
3640
assert span1["tags"]["status"] == "internal_error"
3741
assert span1["op"] == "foo"

0 commit comments

Comments
 (0)
0