File tree Expand file tree Collapse file tree
tests/integrations/falcon Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11from typing import TYPE_CHECKING
22
33import sentry_sdk
4+ from sentry_sdk .consts import SPANDATA
45from sentry_sdk .integrations import DidNotEnable , Integration , _check_minimum_version
56from sentry_sdk .integrations ._wsgi_common import RequestExtractor
67from sentry_sdk .integrations .wsgi import SentryWsgiMiddleware
@@ -116,6 +117,10 @@ def process_resource(
116117 if integration is None or not has_span_streaming_enabled (client .options ):
117118 return
118119
120+ server_span = sentry_sdk .get_current_scope ()._server_segment_span
121+ if server_span is not None :
122+ server_span .set_attribute (SPANDATA .HTTP_ROUTE , req .uri_template )
123+
119124 name_for_style = {
120125 "uri_template" : req .uri_template ,
121126 "path" : req .path ,
Original file line number Diff line number Diff line change @@ -159,6 +159,7 @@ def __call__(
159159 },
160160 parent_span = None ,
161161 )
162+ scope .get_current_scope ()._server_segment_span = span_ctx
162163 else :
163164 transaction = continue_trace (
164165 environ ,
Original file line number Diff line number Diff line change 55import pytest
66
77import sentry_sdk
8+ from sentry_sdk .consts import SPANDATA
89from sentry_sdk .integrations .falcon import FalconIntegration
910from sentry_sdk .integrations .logging import LoggingIntegration
1011from sentry_sdk .utils import parse_version
@@ -155,6 +156,27 @@ def test_transaction_style(
155156 assert event ["transaction_info" ] == {"source" : expected_source }
156157
157158
159+ def test_http_route (
160+ sentry_init ,
161+ make_client ,
162+ capture_items ,
163+ ):
164+ sentry_init (
165+ integrations = [FalconIntegration ()],
166+ traces_sample_rate = 1.0 ,
167+ trace_lifecycle = "stream" ,
168+ )
169+
170+ client = make_client ()
171+ items = capture_items ("span" )
172+
173+ client .simulate_get ("/message/123456" )
174+
175+ sentry_sdk .flush ()
176+ (segment ,) = [item .payload for item in items if item .payload .get ("is_segment" )]
177+ assert segment ["attributes" ][SPANDATA .HTTP_ROUTE ] == "/message/{message_id:int}"
178+
179+
158180@pytest .mark .parametrize ("span_streaming" , [True , False ])
159181def test_unhandled_errors (
160182 sentry_init ,
You can’t perform that action at this time.
0 commit comments