feat(tornado): Support span streaming#6206
Conversation
Codecov Results 📊✅ 282 passed | Total: 282 | Pass Rate: 100% | Execution Time: 42.43s All tests are passing successfully. ❌ Patch coverage is 19.70%. Project has 14825 uncovered lines. Files with missing lines (2)
Generated by Codecov Action |
alexander-alderman-webb
left a comment
There was a problem hiding this comment.
Comment not blocking, looks good to me!
| span.status = "error" if status_int >= 400 else "ok" | ||
|
|
||
|
|
||
| def _get_request_attributes(request: "Any") -> "Dict[str, Any]": |
There was a problem hiding this comment.
Are we still capturing the request body in the streaming path? See https://getsentry.github.io/sentry-conventions/attributes/http/#http-request-body-data
For prior art IIRC @ericapisani did this for another integration, not sure which exactly
| span.status = "error" if status_int >= 400 else "ok" | ||
|
|
||
|
|
||
| def _get_request_attributes(request: "Any") -> "Dict[str, Any]": |
82de412 to
a58538d
Compare
036b60a to
4f36419
Compare
4d430e9 to
2106ec2
Compare
cce1123 to
e390c87
Compare
Add span-streaming support to the Tornado integration. When span streaming is enabled, the request handler emits a StreamedSpan with HTTP request attributes (method, headers, query, URL, client address) and sets the response status on completion. The legacy transaction path is preserved for non-streaming mode. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
e390c87 to
ec6fd01
Compare
| if request.query: | ||
| attributes[SPANDATA.HTTP_QUERY] = request.query | ||
|
|
||
| attributes[SPANDATA.URL_FULL] = "%s://%s%s" % ( | ||
| request.protocol, |
There was a problem hiding this comment.
Bug: The Tornado integration incorrectly populates url.full without the query string and uses the wrong attribute key (http.query) for the query string itself.
Severity: LOW
Suggested Fix
To fix the url.full attribute, append request.query if it exists, prefixed with a ?. To address the incorrect attribute key, assign request.query to SPANDATA.URL_QUERY (url.query) instead of SPANDATA.HTTP_QUERY. Alternatively, if using http.query is desired, prepend a ? to request.query before assignment.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: sentry_sdk/integrations/tornado.py#L197-L201
Potential issue: In the Tornado integration's span streaming path, the `url.full`
attribute is constructed using `request.path`, which omits the query string, contrary to
OpenTelemetry and Sentry conventions. Additionally, the request's query string, which
lacks a leading `?`, is assigned to the `http.query` attribute (`SPANDATA.HTTP_QUERY`).
Per Sentry's constants, `http.query` should include the `?`, and the query string
without the `?` should be assigned to `url.query` (`SPANDATA.URL_QUERY`). This results
in non-compliant and potentially misleading span data.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 1fa438a. Configure here.

Issues