@@ -82,16 +82,23 @@ def _looks_like_asgi3(app):
8282
8383
8484class SentryAsgiMiddleware :
85- __slots__ = ("app" , "__call__" , "transaction_style" , "mechanism_type" )
85+ __slots__ = (
86+ "app" ,
87+ "__call__" ,
88+ "transaction_style" ,
89+ "mechanism_type" ,
90+ "span_origin" ,
91+ )
8692
8793 def __init__ (
8894 self ,
8995 app ,
9096 unsafe_context_data = False ,
9197 transaction_style = "endpoint" ,
9298 mechanism_type = "asgi" ,
99+ span_origin = "manual" ,
93100 ):
94- # type: (Any, bool, str, str) -> None
101+ # type: (Any, bool, str, str, str ) -> None
95102 """
96103 Instrument an ASGI application with Sentry. Provides HTTP/websocket
97104 data to sent events and basic handling for exceptions bubbling up
@@ -124,6 +131,7 @@ def __init__(
124131
125132 self .transaction_style = transaction_style
126133 self .mechanism_type = mechanism_type
134+ self .span_origin = span_origin
127135 self .app = app
128136
129137 if _looks_like_asgi3 (app ):
@@ -182,6 +190,7 @@ async def _run_app(self, scope, receive, send, asgi_version):
182190 op = "{}.server" .format (ty ),
183191 name = transaction_name ,
184192 source = transaction_source ,
193+ origin = self .span_origin ,
185194 )
186195 logger .debug (
187196 "[ASGI] Created transaction (continuing trace): %s" ,
@@ -192,6 +201,7 @@ async def _run_app(self, scope, receive, send, asgi_version):
192201 op = OP .HTTP_SERVER ,
193202 name = transaction_name ,
194203 source = transaction_source ,
204+ origin = self .span_origin ,
195205 )
196206 logger .debug (
197207 "[ASGI] Created transaction (new): %s" , transaction
@@ -205,7 +215,8 @@ async def _run_app(self, scope, receive, send, asgi_version):
205215 )
206216
207217 with sentry_sdk .start_transaction (
208- transaction , custom_sampling_context = {"asgi_scope" : scope }
218+ transaction ,
219+ custom_sampling_context = {"asgi_scope" : scope },
209220 ):
210221 logger .debug ("[ASGI] Started transaction: %s" , transaction )
211222 try :
0 commit comments