@@ -82,16 +82,23 @@ def _looks_like_asgi3(app):
82
82
83
83
84
84
class 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
+ )
86
92
87
93
def __init__ (
88
94
self ,
89
95
app ,
90
96
unsafe_context_data = False ,
91
97
transaction_style = "endpoint" ,
92
98
mechanism_type = "asgi" ,
99
+ span_origin = "manual" ,
93
100
):
94
- # type: (Any, bool, str, str) -> None
101
+ # type: (Any, bool, str, str, str ) -> None
95
102
"""
96
103
Instrument an ASGI application with Sentry. Provides HTTP/websocket
97
104
data to sent events and basic handling for exceptions bubbling up
@@ -124,6 +131,7 @@ def __init__(
124
131
125
132
self .transaction_style = transaction_style
126
133
self .mechanism_type = mechanism_type
134
+ self .span_origin = span_origin
127
135
self .app = app
128
136
129
137
if _looks_like_asgi3 (app ):
@@ -182,6 +190,7 @@ async def _run_app(self, scope, receive, send, asgi_version):
182
190
op = "{}.server" .format (ty ),
183
191
name = transaction_name ,
184
192
source = transaction_source ,
193
+ origin = self .span_origin ,
185
194
)
186
195
logger .debug (
187
196
"[ASGI] Created transaction (continuing trace): %s" ,
@@ -192,6 +201,7 @@ async def _run_app(self, scope, receive, send, asgi_version):
192
201
op = OP .HTTP_SERVER ,
193
202
name = transaction_name ,
194
203
source = transaction_source ,
204
+ origin = self .span_origin ,
195
205
)
196
206
logger .debug (
197
207
"[ASGI] Created transaction (new): %s" , transaction
@@ -205,7 +215,8 @@ async def _run_app(self, scope, receive, send, asgi_version):
205
215
)
206
216
207
217
with sentry_sdk .start_transaction (
208
- transaction , custom_sampling_context = {"asgi_scope" : scope }
218
+ transaction ,
219
+ custom_sampling_context = {"asgi_scope" : scope },
209
220
):
210
221
logger .debug ("[ASGI] Started transaction: %s" , transaction )
211
222
try :
0 commit comments