diff --git a/sentry_sdk/integrations/falcon.py b/sentry_sdk/integrations/falcon.py index a1a0df9fcd..5ee687ea9b 100644 --- a/sentry_sdk/integrations/falcon.py +++ b/sentry_sdk/integrations/falcon.py @@ -5,6 +5,7 @@ from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version from sentry_sdk.integrations._wsgi_common import RequestExtractor from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware +from sentry_sdk.traces import SegmentNameSource from sentry_sdk.utils import ( capture_internal_exceptions, ensure_integration_enabled, @@ -100,32 +101,13 @@ def process_resource( if server_span is not None: server_span.set_attribute(SPANDATA.HTTP_ROUTE, req.uri_template) - name_for_style = { - "uri_template": req.uri_template, - "path": req.path, - } - name = name_for_style[integration.transaction_style] - source = sentry_sdk.traces.SOURCE_FOR_STYLE[integration.transaction_style] - sentry_sdk.set_transaction_name(name, source) - - -TRANSACTION_STYLE_VALUES = ("uri_template", "path") + sentry_sdk.set_transaction_name(req.uri_template, SegmentNameSource.ROUTE) class FalconIntegration(Integration): identifier = "falcon" origin = f"auto.http.{identifier}" - transaction_style = "" - - def __init__(self, transaction_style: str = "uri_template") -> None: - if transaction_style not in TRANSACTION_STYLE_VALUES: - raise ValueError( - f"Invalid value for transaction_style: {transaction_style} " - f"(must be in {TRANSACTION_STYLE_VALUES})" - ) - self.transaction_style = transaction_style - @staticmethod def setup_once() -> None: _check_minimum_version(FalconIntegration, parse_version(FALCON_VERSION)) diff --git a/tests/integrations/falcon/test_falcon.py b/tests/integrations/falcon/test_falcon.py index 53f4ae5035..0cc3e83a7f 100644 --- a/tests/integrations/falcon/test_falcon.py +++ b/tests/integrations/falcon/test_falcon.py @@ -85,24 +85,21 @@ def test_has_context( @pytest.mark.parametrize( - "url,transaction_style,expected_transaction,expected_source", + "url,expected_transaction,expected_source", [ - ("/message", "uri_template", "/message", "route"), - ("/message", "path", "/message", "url"), - ("/message/123456", "uri_template", "/message/{message_id:int}", "route"), - ("/message/123456", "path", "/message/123456", "url"), + ("/message", "/message", "route"), + ("/message/123456", "/message/{message_id:int}", "route"), ], ) -def test_transaction_style( +def test_segment_name_and_source( sentry_init, make_client, capture_items, url, - transaction_style, expected_transaction, expected_source, ): - integration = FalconIntegration(transaction_style=transaction_style) + integration = FalconIntegration() sentry_init( integrations=[integration], traces_sample_rate=1.0,