@@ -246,13 +246,19 @@ async def _run_app(
246246 span_ctx : "ContextManager[Union[Span, StreamedSpan, None]]"
247247 if span_streaming :
248248 segment : "Optional[StreamedSpan]" = None
249+ segment_source = getattr (
250+ transaction_source , "value" , transaction_source
251+ )
249252 attributes : "Attributes" = {
250- "sentry.segment.name.source" : getattr (
251- transaction_source , "value" , transaction_source
252- ),
253+ "sentry.segment.name.source" : segment_source ,
253254 "sentry.origin" : self .span_origin ,
254255 "network.protocol.name" : ty ,
255256 }
257+ if (
258+ segment_source == SegmentNameSource .ROUTE .value
259+ and transaction_name != _DEFAULT_TRANSACTION_NAME
260+ ):
261+ attributes [SPANDATA .HTTP_ROUTE ] = transaction_name
256262
257263 if scope .get ("client" ):
258264 client_options = sentry_sdk .get_client ().options
@@ -412,6 +418,13 @@ async def _sentry_wrapped_send(
412418 span .set_attribute (
413419 "sentry.segment.name.source" , source
414420 )
421+ if (
422+ source == SegmentNameSource .ROUTE .value
423+ and name != _DEFAULT_TRANSACTION_NAME
424+ ):
425+ span .set_attribute (
426+ SPANDATA .HTTP_ROUTE , name
427+ )
415428 finally :
416429 _asgi_middleware_applied .set (False )
417430
0 commit comments