Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 29 additions & 18 deletions tests/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -914,23 +914,30 @@ def _hello_world(word):


def test_functions_to_trace(sentry_init, capture_events):
global _hello_world

functions_to_trace = [
{"qualified_name": "tests.test_basics._hello_world"},
{"qualified_name": "time.sleep"},
]

sentry_init(
traces_sample_rate=1.0,
functions_to_trace=functions_to_trace,
)
try:
sentry_init(
traces_sample_rate=1.0,
functions_to_trace=functions_to_trace,
)

events = capture_events()
events = capture_events()

with start_transaction(name="something"):
time.sleep(0)
with start_transaction(name="something"):
time.sleep(0)

for word in ["World", "You"]:
_hello_world(word)
for word in ["World", "You"]:
_hello_world(word)

finally:
_hello_world = _hello_world.__wrapped__
time.sleep = time.sleep.__wrapped__

assert len(events) == 1

Expand All @@ -955,17 +962,21 @@ def test_functions_to_trace_with_class(sentry_init, capture_events):
{"qualified_name": "tests.test_basics.WorldGreeter.greet"},
]

sentry_init(
traces_sample_rate=1.0,
functions_to_trace=functions_to_trace,
)
try:
sentry_init(
traces_sample_rate=1.0,
functions_to_trace=functions_to_trace,
)

events = capture_events()
events = capture_events()

with start_transaction(name="something"):
wg = WorldGreeter("World")
wg.greet()
wg.greet("You")
with start_transaction(name="something"):
wg = WorldGreeter("World")
wg.greet()
wg.greet("You")

finally:
WorldGreeter.greet = WorldGreeter.greet.__wrapped__

assert len(events) == 1

Expand Down
Loading