FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ref(pyreqwest): Move crumbs to integration by sentrivana · Pull Request #7148 · getsentry/sentry-python · GitHub

ref(pyreqwest): Move crumbs to integration - #7148

Merged
sentrivana merged 34 commits into
masterfrom
ivana/move-http-crumbs-2
Aug 12, 2026
Merged

ref(pyreqwest): Move crumbs to integration#7148
sentrivana merged 34 commits into
masterfrom
ivana/move-http-crumbs-2

Conversation

sentrivana commented Aug 10, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Description

Create HTTP client breadcrumbs directly in the pyreqwest integration instead of using maybe_create_breadcrumbs_from_span.

Additionally:

  • refactor to use an early return in the wrapper to avoid nesting
  • add breadcrumb tests to the pyreqwest test suite

Issues

Reminders

github-actions Bot commented Aug 10, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Codecov Results 📊

111463 passed | ⏭️ 6749 skipped | Total: 118212 | Pass Rate: 94.29% | Execution Time: 404m 41s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +108
Passed Tests 📈 +108
Failed Tests
Skipped Tests

All tests are passing successfully.

✅ Patch coverage is 96.55%. Project has 2483 uncovered lines.
✅ Project coverage is 90.2%. Comparing base (base) to head (head).

Files with missing lines (1)
File Patch % Lines
sentry_sdk/integrations/pyreqwest.py 96.43% ⚠️ 1 Missing and 3 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    90.16%    90.20%    +0.04%
==========================================
  Files          193       193         —
  Lines        25317     25337       +20
  Branches      9280      9286        +6
==========================================
+ Hits         22827     22854       +27
- Misses        2490      2483        -7
- Partials      1427      1427         —

Generated by Codecov Action

sentrivana marked this pull request as ready for review August 10, 2026 09:16
sentrivana requested a review from a team as a code owner August 10, 2026 09:16
Comment thread sentry_sdk/integrations/pyreqwest.py Outdated
Comment thread sentry_sdk/integrations/pyreqwest.py Outdated
Comment thread sentry_sdk/integrations/pyreqwest.py Outdated
sentrivana marked this pull request as draft August 10, 2026 09:53
sentrivana marked this pull request as ready for review August 10, 2026 10:21

cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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 e31a3aa. Configure here.

Base automatically changed from ivana/move-http-crumbs-1 to master August 12, 2026 11:53
sentrivana enabled auto-merge (squash) August 12, 2026 11:56
sentrivana merged commit e4d7398 into master Aug 12, 2026
139 checks passed
sentrivana deleted the ivana/move-http-crumbs-2 branch August 12, 2026 12:07
from sentry_sdk.traces import StreamedSpan
from sentry_sdk.tracing import BAGGAGE_HEADER_NAME
from sentry_sdk.tracing_utils import (
add_http_breadcrumb,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

pyreqwest middleware skips breadcrumbs when HTTP requests raise exceptions

If next_handler.run(request) raises an exception (network error, timeout), the middleware skips breadcrumb creation because it only runs inside if response is not None:. The old fallback via Span.finish() and maybe_create_breadcrumbs_from_span no longer applies since tracing_utils.py now explicitly excludes pyreqwest ("auto.http.pyreqwest") from that path. As a result, connection-level failures produce no HTTP breadcrumb at all. Both sentry_async_middleware (~172) and sentry_sync_middleware (~217) share this flaw.

Evidence
  • sentry_async_middleware (line 172) and sentry_sync_middleware (line 217) set response = None, execute the request inside with _sentry_pyreqwest_span(...), and only call add_http_breadcrumb inside if response is not None: after the block.
  • If next_handler.run(request) raises, control jumps past the crumb code and response stays None.
  • maybe_create_breadcrumbs_from_span in tracing_utils.py:228-246 now skips span.origin == "auto.http.pyreqwest", so no fallback breadcrumb is recorded.
  • StreamedSpan.__exit__ marks the span as error but never creates a breadcrumb, and the old Span.finish() breadcrumb path is likewise blocked for this origin.
  • The new test suite (test_pyreqwest.py) includes happy-path breadcrumb tests but no test simulating a connection-level exception.

Identified by Warden · find-bugs · CGK-YBX

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL