Skip to content

Commit

Permalink
Fix scope transaction source not being updated in scope.span setter (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
sl0thentr0py committed Nov 21, 2023
1 parent 5cab03f commit ea55387
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,8 @@ def span(self, span):
transaction = span
if transaction.name:
self._transaction = transaction.name
if transaction.source:
self._transaction_info["source"] = transaction.source

@property
def profile(self):
Expand Down
11 changes: 10 additions & 1 deletion tests/tracing/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os

import sentry_sdk
from sentry_sdk import Hub, start_span, start_transaction, set_measurement
from sentry_sdk import Hub, start_span, start_transaction, set_measurement, push_scope
from sentry_sdk.consts import MATCH_ALL
from sentry_sdk.tracing import Span, Transaction
from sentry_sdk.tracing_utils import should_propagate_trace
Expand Down Expand Up @@ -357,3 +357,12 @@ def test_should_propagate_trace_to_sentry(
Hub.current.client.transport.parsed_dsn = Dsn(dsn)

assert should_propagate_trace(Hub.current, url) == expected_propagation_decision


def test_start_transaction_updates_scope_name_source(sentry_init):
sentry_init(traces_sample_rate=1.0)

with push_scope() as scope:
with start_transaction(name="foobar", source="route"):
assert scope._transaction == "foobar"
assert scope._transaction_info == {"source": "route"}

0 comments on commit ea55387

Please sign in to comment.