|
14 | 14 |
|
15 | 15 |
|
16 | 16 | @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): |
18 | 19 | sentry_init(traces_sample_rate=sample_rate)
|
19 | 20 | events = capture_events()
|
20 | 21 |
|
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 |
26 | 29 |
|
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 |
29 | 33 |
|
30 | 34 | if sample_rate:
|
31 |
| - assert len(events) == 1 |
32 | 35 | event = events[0]
|
33 | 36 |
|
34 |
| - span1, span2 = event["spans"] |
| 37 | + assert len(event['spans']) == num_spans + 1 |
| 38 | + span1, span2 = event["spans"][:2] |
35 | 39 | parent_span = event
|
36 | 40 | assert span1["tags"]["status"] == "internal_error"
|
37 | 41 | assert span1["op"] == "foo"
|
|
0 commit comments