Skip to content

Commit ab325ea

Browse files
always set SegmentNameSource.ROUTE in asgi.py
1 parent 7b6c588 commit ab325ea

1 file changed

Lines changed: 7 additions & 15 deletions

File tree

‎sentry_sdk/integrations/asgi.py‎

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,14 @@ async def _run_app(
202202
)
203203

204204
ty = scope["type"]
205-
(
206-
transaction_name,
207-
transaction_source,
208-
) = self._get_transaction_name_and_source(scope)
205+
transaction_name = self._get_transaction_name(scope)
209206

210207
method = scope.get("method", "").upper()
211208

212209
span: "Optional[ContextManager[Optional[Span]]]" = None
213210
attributes: "Attributes" = {
214211
"sentry.segment.name.source": getattr(
215-
transaction_source, "value", transaction_source
212+
SegmentNameSource.ROUTE, "value", SegmentNameSource.ROUTE
216213
),
217214
"sentry.origin": self.span_origin,
218215
"network.protocol.name": ty,
@@ -346,9 +343,9 @@ def event_processor(
346343
]
347344
)
348345
if not already_set:
349-
name, source = self._get_transaction_name_and_source(asgi_scope)
346+
name = self._get_transaction_name(asgi_scope)
350347
event["transaction"] = name
351-
event["transaction_info"] = {"source": source}
348+
event["transaction_info"] = {"source": SegmentNameSource.ROUTE}
352349

353350
return event
354351

@@ -358,11 +355,8 @@ def event_processor(
358355
# data to your liking it's recommended to use the `before_send` callback
359356
# for that.
360357

361-
def _get_transaction_name_and_source(
362-
self: "SentryAsgiMiddleware", asgi_scope: "Any"
363-
) -> "Tuple[str, str]":
358+
def _get_transaction_name(self: "SentryAsgiMiddleware", asgi_scope: "Any") -> "str":
364359
name = None
365-
source = SegmentNameSource.URL
366360

367361
# FastAPI includes the route object in the scope to let Sentry extract the
368362
# path from it for the transaction name
@@ -382,11 +376,9 @@ def _get_transaction_name_and_source(
382376
)
383377

384378
if name is None:
385-
name = _DEFAULT_TRANSACTION_NAME
386-
source = SegmentNameSource.ROUTE
387-
return name, source
379+
return _DEFAULT_TRANSACTION_NAME
388380

389-
return name, source
381+
return name
390382

391383
def _get_segment_name_and_source(
392384
self: "SentryAsgiMiddleware", asgi_scope: "Any"

0 commit comments

Comments
 (0)