Skip to content
Open
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
15 changes: 15 additions & 0 deletions sentry_sdk/integrations/falcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ def process_request(
scope._name = "falcon"
scope.add_event_processor(_make_request_event_processor(req, integration))

def process_resource(
self, req: "Any", resp: "Any", resource: "Any", params: "Any"
) -> None:
integration = sentry_sdk.get_client().get_integration(FalconIntegration)
if integration is None:
return

name_for_style = {
"uri_template": req.uri_template,
"path": req.path,
}
name = name_for_style[integration.transaction_style]
source = SOURCE_FOR_STYLE[integration.transaction_style]
Comment thread
alexander-alderman-webb marked this conversation as resolved.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If, based on my understanding of the pull request description, process_resource is intended t be run when span streaming is enabled, should this instead be using the SOURCE_FOR_STYLE from sentry_sdk.traces instead of sentry_sdk.tracing?

sentry_sdk.set_transaction_name(name, source)


TRANSACTION_STYLE_VALUES = ("uri_template", "path")

Expand Down
16 changes: 14 additions & 2 deletions tests/integrations/falcon/test_falcon.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,24 +121,36 @@ def test_transaction_style(
integration = FalconIntegration(transaction_style=transaction_style)
sentry_init(
integrations=[integration],
traces_sample_rate=1.0,
_experiments={"trace_lifecycle": "stream" if span_streaming else "static"},
)

client = make_client()
if span_streaming:
items = capture_items("event")
items = capture_items("event", "span")

response = client.simulate_get(url)
assert response.status == falcon.HTTP_200

(event,) = (item.payload for item in items)
(event,) = (item.payload for item in items if item.type == "event")

sentry_sdk.flush()
spans = [item.payload for item in items if item.type == "span"]
spans = [span for span in spans if span["name"] == expected_transaction]
assert len(spans) == 1
assert spans[0]["attributes"]["sentry.span.source"] == expected_source
else:
events = capture_events()

response = client.simulate_get(url)
assert response.status == falcon.HTTP_200

(event,) = events
(event, transaction) = events

assert transaction["transaction"] == expected_transaction
assert transaction["transaction_info"] == {"source": expected_source}

assert event["transaction"] == expected_transaction
assert event["transaction_info"] == {"source": expected_source}

Expand Down
Loading