File tree Expand file tree Collapse file tree 3 files changed +24
-8
lines changed
Expand file tree Collapse file tree 3 files changed +24
-8
lines changed Original file line number Diff line number Diff line change @@ -362,13 +362,24 @@ async def _sentry_wrapped_send(
362362 reraise (* exc_info )
363363
364364 finally :
365- with capture_internal_exceptions ():
366- name , source = self ._get_segment_name_and_source (
367- self .transaction_style , scope
365+ if isinstance (span , StreamedSpan ):
366+ already_set = (
367+ span is not None
368+ and span .name != _DEFAULT_TRANSACTION_NAME
369+ and span .get_attributes ().get ("sentry.span.source" )
370+ in [
371+ SegmentSource .COMPONENT .value ,
372+ SegmentSource .ROUTE .value ,
373+ SegmentSource .CUSTOM .value ,
374+ ]
368375 )
369- if isinstance (span , StreamedSpan ):
370- span .name = name
371- span .set_attribute ("sentry.span.source" , source )
376+ with capture_internal_exceptions ():
377+ if not already_set :
378+ name , source = self ._get_segment_name_and_source (
379+ self .transaction_style , scope
380+ )
381+ span .name = name
382+ span .set_attribute ("sentry.span.source" , source )
372383 finally :
373384 _asgi_middleware_applied .set (False )
374385
Original file line number Diff line number Diff line change @@ -259,6 +259,7 @@ def __init__(
259259 self ._name : str = name
260260 self ._active : bool = active
261261 self ._attributes : "Attributes" = {}
262+
262263 if attributes :
263264 for attribute , value in attributes .items ():
264265 self .set_attribute (attribute , value )
@@ -287,7 +288,6 @@ def __init__(
287288 self ._span_id : "Optional[str]" = None
288289
289290 self ._status = SpanStatus .OK .value
290- self .set_attribute ("sentry.span.source" , SegmentSource .CUSTOM .value )
291291
292292 self ._update_active_thread ()
293293
Original file line number Diff line number Diff line change @@ -329,7 +329,12 @@ class UnwrappedItem:
329329
330330@pytest .fixture
331331def capture_items (monkeypatch ):
332- """Capture envelope payload, unfurling individual items."""
332+ """
333+ Capture envelope payload, unfurling individual items.
334+
335+ Makes it easier to work with both events and attribute-based telemetry in
336+ one test.
337+ """
333338
334339 def inner (* types ):
335340 telemetry = []
You can’t perform that action at this time.
0 commit comments