Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions sentry_sdk/integrations/falcon.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import TYPE_CHECKING

import sentry_sdk
from sentry_sdk.consts import SPANDATA
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
Expand Down Expand Up @@ -116,6 +117,10 @@ def process_resource(
if integration is None or not has_span_streaming_enabled(client.options):
return

server_span = sentry_sdk.get_current_scope()._server_segment_span
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,
Expand Down
1 change: 1 addition & 0 deletions sentry_sdk/integrations/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ def __call__(
},
parent_span=None,
)
scope.get_current_scope()._server_segment_span = span_ctx
else:
transaction = continue_trace(
environ,
Expand Down
22 changes: 22 additions & 0 deletions tests/integrations/falcon/test_falcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pytest

import sentry_sdk
from sentry_sdk.consts import SPANDATA
from sentry_sdk.integrations.falcon import FalconIntegration
from sentry_sdk.integrations.logging import LoggingIntegration
from sentry_sdk.utils import parse_version
Expand Down Expand Up @@ -155,6 +156,27 @@ def test_transaction_style(
assert event["transaction_info"] == {"source": expected_source}


def test_http_route(
sentry_init,
make_client,
capture_items,
):
sentry_init(
integrations=[FalconIntegration()],
traces_sample_rate=1.0,
trace_lifecycle="stream",
)

client = make_client()
items = capture_items("span")

client.simulate_get("/message/123456")

sentry_sdk.flush()
(segment,) = [item.payload for item in items if item.payload.get("is_segment")]
assert segment["attributes"][SPANDATA.HTTP_ROUTE] == "/message/{message_id:int}"


@pytest.mark.parametrize("span_streaming", [True, False])
def test_unhandled_errors(
sentry_init,
Expand Down
Loading