File tree Expand file tree Collapse file tree 3 files changed +19
-1
lines changed
integrations/opentelemetry Expand file tree Collapse file tree 3 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -138,6 +138,7 @@ def should_sample(
138138 "transaction_context" : {
139139 "name" : name ,
140140 "op" : attributes .get (SentrySpanAttribute .OP ),
141+ "source" : attributes .get (SentrySpanAttribute .SOURCE ),
141142 },
142143 "parent_sampled" : get_parent_sampled (parent_span_context , trace_id ),
143144 }
Original file line number Diff line number Diff line change @@ -1250,6 +1250,7 @@ def __init__(
12501250 # Prepopulate some attrs so that they're accessible in traces_sampler
12511251 attributes = attributes or {}
12521252 attributes [SentrySpanAttribute .OP ] = op
1253+ attributes [SentrySpanAttribute .SOURCE ] = source
12531254 if sampled is not None :
12541255 attributes [SentrySpanAttribute .CUSTOM_SAMPLED ] = sampled
12551256
@@ -1260,7 +1261,6 @@ def __init__(
12601261 self .origin = origin or DEFAULT_SPAN_ORIGIN
12611262 self .description = description
12621263 self .name = span_name
1263- self .source = source
12641264
12651265 if status is not None :
12661266 self .set_status (status )
Original file line number Diff line number Diff line change @@ -721,3 +721,20 @@ async def test_custom_transaction_name(
721721 assert transaction_event ["type" ] == "transaction"
722722 assert transaction_event ["transaction" ] == "foobar"
723723 assert transaction_event ["transaction_info" ] == {"source" : "custom" }
724+
725+
726+ @pytest .mark .asyncio
727+ async def test_asgi_scope_in_traces_sampler (sentry_init , asgi3_app ):
728+ def dummy_traces_sampler (sampling_context ):
729+ assert sampling_context ["asgi_scope.path" ] == "/test"
730+ assert sampling_context ["asgi_scope.scheme" ] == "http"
731+
732+ sentry_init (
733+ traces_sampler = dummy_traces_sampler ,
734+ traces_sample_rate = 1.0 ,
735+ )
736+
737+ app = SentryAsgiMiddleware (asgi3_app )
738+
739+ async with TestClient (app ) as client :
740+ await client .get ("/test" )
You can’t perform that action at this time.
0 commit comments