feat(pyreqwest): Support span streaming - #6455
Conversation
Codecov Results 📊✅ 88173 passed | ⏭️ 6009 skipped | Total: 94182 | Pass Rate: 93.62% | Execution Time: 298m 8s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 100.00%. Project has 2313 uncovered lines. Coverage diff@@ Coverage Diff @@
## main #PR +/-##
==========================================
+ Coverage 89.96% 89.97% +0.01%
==========================================
Files 191 191 —
Lines 23031 23055 +24
Branches 7906 7920 +14
==========================================
+ Hits 20719 20742 +23
- Misses 2312 2313 +1
- Partials 1306 1307 +1Generated by Codecov Action |
There was a problem hiding this comment.
test_no_request_source_if_duration_too_short (streaming) checks the wrong span field, making assertions vacuously true
In the streaming branch of test_no_request_source_if_duration_too_short (test file line ~814), data = span.get("data", {}) should be span.get("attributes", {}). Streaming spans expose source code fields under "attributes" (as every other streaming test does), so "data" always returns {} and the not in assertions trivially pass — the test never validates that request-source data is actually absent. Additionally, the mocked _end_timestamp is set to microsecond=100001 (100.001 ms), which exceeds the 100 ms threshold, so if the key were corrected the test would fail because source data would be added; the timestamp should be set to something below the threshold (e.g. microsecond=99999) to match the intent of the non-streaming branch.
Evidence
test_request_source_if_duration_over_threshold(streaming) usesspan.get("attributes", {})and asserts the keys are present — consistent with streaming spans storing data in"attributes".test_no_request_source_if_duration_too_short(streaming, line ~814) usesspan.get("data", {}), which returns{}for streaming spans;not in {}is alwaysTrue.- Both tests mock
_end_timestamp = datetime(2024, 1, 1, microsecond=100001)(100.001 ms). Withhttp_request_source_threshold_ms=100,add_http_request_sourceevaluates100.001 > 100 → Trueand adds source; the "too short" test's end timestamp should bemicrosecond=99999(< 100 ms) to mirror the non-streaming branch'smicrosecond=99999. add_http_request_sourceis called inside thewith sentry_sdk.traces.start_span()block afteryield span, so_end_timestampis still the mocked value (not yet reset toNone) when the duration check runs.
Identified by Warden code-review
sentrivana
left a comment
There was a problem hiding this comment.
LGTM! Would just remove the extra filtering by item.type == "span" in the tests where not necessary
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 76b9dd6. Configure here.
Replace deprecated `http.method` and `url` attributes with `http.request.method` and `url.full` attributes in the streaming lifecycle mode. Use `url.query` and `url.fragment` instead of `http.query` and `http.fragment` in the streaming mode.

Description
In the streaming path, use
code.filepathinstead ofcode.file.pathcode.line.numberinstead ofcode.linenourl.fullinstead ofurlurl.queryinstead ofhttp.queryurl.fragmentinstead ofhttp.fragmenthttp.request.methodinstead ofhttp.methodAdapting Tests
sedcommands used for converting transaction context managers:sedcommands used for converting specific attributes:sedcommands used for converting event capture:sedcommands used for convertingop:sedcommands used for converting origin:sedcommands used for convertingdescription:sedcommands used for convertingdatatoattributes:other test changes:
Issues
Reminders
uv run ruff.feat:,fix:,ref:,meta:)