Skip to content

Commit ea55387

Browse files
authored
Fix scope transaction source not being updated in scope.span setter (#2519)
1 parent 5cab03f commit ea55387

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

sentry_sdk/scope.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,8 @@ def span(self, span):
430430
transaction = span
431431
if transaction.name:
432432
self._transaction = transaction.name
433+
if transaction.source:
434+
self._transaction_info["source"] = transaction.source
433435

434436
@property
435437
def profile(self):

tests/tracing/test_misc.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import os
55

66
import sentry_sdk
7-
from sentry_sdk import Hub, start_span, start_transaction, set_measurement
7+
from sentry_sdk import Hub, start_span, start_transaction, set_measurement, push_scope
88
from sentry_sdk.consts import MATCH_ALL
99
from sentry_sdk.tracing import Span, Transaction
1010
from sentry_sdk.tracing_utils import should_propagate_trace
@@ -357,3 +357,12 @@ def test_should_propagate_trace_to_sentry(
357357
Hub.current.client.transport.parsed_dsn = Dsn(dsn)
358358

359359
assert should_propagate_trace(Hub.current, url) == expected_propagation_decision
360+
361+
362+
def test_start_transaction_updates_scope_name_source(sentry_init):
363+
sentry_init(traces_sample_rate=1.0)
364+
365+
with push_scope() as scope:
366+
with start_transaction(name="foobar", source="route"):
367+
assert scope._transaction == "foobar"
368+
assert scope._transaction_info == {"source": "route"}

0 commit comments

Comments
 (0)