File: test_span_name.py

package info (click to toggle)
sentry-python 2.18.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,004 kB
  • sloc: python: 55,908; makefile: 114; sh: 111; xml: 2
file content (59 lines) | stat: -rw-r--r-- 1,688 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import pytest

import sentry_sdk


def test_start_span_description(sentry_init, capture_events):
    sentry_init(traces_sample_rate=1.0)
    events = capture_events()

    with sentry_sdk.start_transaction(name="hi"):
        with pytest.deprecated_call():
            with sentry_sdk.start_span(op="foo", description="span-desc"):
                ...

    (event,) = events

    assert event["spans"][0]["description"] == "span-desc"


def test_start_span_name(sentry_init, capture_events):
    sentry_init(traces_sample_rate=1.0)
    events = capture_events()

    with sentry_sdk.start_transaction(name="hi"):
        with sentry_sdk.start_span(op="foo", name="span-name"):
            ...

    (event,) = events

    assert event["spans"][0]["description"] == "span-name"


def test_start_child_description(sentry_init, capture_events):
    sentry_init(traces_sample_rate=1.0)
    events = capture_events()

    with sentry_sdk.start_transaction(name="hi"):
        with pytest.deprecated_call():
            with sentry_sdk.start_span(op="foo", description="span-desc") as span:
                with span.start_child(op="bar", description="child-desc"):
                    ...

    (event,) = events

    assert event["spans"][-1]["description"] == "child-desc"


def test_start_child_name(sentry_init, capture_events):
    sentry_init(traces_sample_rate=1.0)
    events = capture_events()

    with sentry_sdk.start_transaction(name="hi"):
        with sentry_sdk.start_span(op="foo", name="span-name") as span:
            with span.start_child(op="bar", name="child-name"):
                ...

    (event,) = events

    assert event["spans"][-1]["description"] == "child-name"