25
25
from sentry_sdk .sessions import track_session
26
26
from sentry_sdk .tracing import (
27
27
SOURCE_FOR_STYLE ,
28
- TRANSACTION_SOURCE_ROUTE ,
29
- TRANSACTION_SOURCE_URL ,
30
- TRANSACTION_SOURCE_COMPONENT ,
31
- TRANSACTION_SOURCE_CUSTOM ,
28
+ TransactionSource ,
32
29
)
33
30
from sentry_sdk .utils import (
34
31
ContextVar ,
@@ -273,9 +270,9 @@ def event_processor(self, event, hint, asgi_scope):
273
270
already_set = event ["transaction" ] != _DEFAULT_TRANSACTION_NAME and event [
274
271
"transaction_info"
275
272
].get ("source" ) in [
276
- TRANSACTION_SOURCE_COMPONENT ,
277
- TRANSACTION_SOURCE_ROUTE ,
278
- TRANSACTION_SOURCE_CUSTOM ,
273
+ TransactionSource . COMPONENT ,
274
+ TransactionSource . ROUTE ,
275
+ TransactionSource . CUSTOM ,
279
276
]
280
277
if not already_set :
281
278
name , source = self ._get_transaction_name_and_source (
@@ -299,7 +296,7 @@ def event_processor(self, event, hint, asgi_scope):
299
296
# for that.
300
297
301
298
def _get_transaction_name_and_source (self , transaction_style , asgi_scope ):
302
- # type: (SentryAsgiMiddleware, str, Any) -> Tuple[str, str ]
299
+ # type: (SentryAsgiMiddleware, str, Any) -> Tuple[str, TransactionSource ]
303
300
name = None
304
301
source = SOURCE_FOR_STYLE [transaction_style ]
305
302
ty = asgi_scope .get ("type" )
@@ -313,7 +310,7 @@ def _get_transaction_name_and_source(self, transaction_style, asgi_scope):
313
310
name = transaction_from_function (endpoint ) or ""
314
311
else :
315
312
name = _get_url (asgi_scope , "http" if ty == "http" else "ws" , host = None )
316
- source = TRANSACTION_SOURCE_URL
313
+ source = TransactionSource . URL
317
314
318
315
elif transaction_style == "url" :
319
316
# FastAPI includes the route object in the scope to let Sentry extract the
@@ -325,11 +322,11 @@ def _get_transaction_name_and_source(self, transaction_style, asgi_scope):
325
322
name = path
326
323
else :
327
324
name = _get_url (asgi_scope , "http" if ty == "http" else "ws" , host = None )
328
- source = TRANSACTION_SOURCE_URL
325
+ source = TransactionSource . URL
329
326
330
327
if name is None :
331
328
name = _DEFAULT_TRANSACTION_NAME
332
- source = TRANSACTION_SOURCE_ROUTE
329
+ source = TransactionSource . ROUTE
333
330
return name , source
334
331
335
332
return name , source
0 commit comments