Skip to content

ref: Move HTTP client breadcrumbs to integrations (1) - #7130

Closed
sentrivana wants to merge 5 commits into
ivana/move-redis-breadcrumbs-to-integrationfrom
ivana/move-http-client-breadcrumbs-1
Closed

ref: Move HTTP client breadcrumbs to integrations (1)#7130
sentrivana wants to merge 5 commits into
ivana/move-redis-breadcrumbs-to-integrationfrom
ivana/move-http-client-breadcrumbs-1

Conversation

@sentrivana

Copy link
Copy Markdown
Contributor

Description

Move breadcrumbs created by HTTP client integrations to the integrations themselves, instead of relying on span data.

This PR has everything but stdlib in it.

Issues

Part 1/2 of #7067

Reminders

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

99250 passed | ⏭️ 6479 skipped | Total: 105729 | Pass Rate: 93.87% | Execution Time: 347m 49s

📊 Comparison with Base Branch

Metric Change
Total Tests
Passed Tests 📈 +1
Failed Tests 📉 -1
Skipped Tests

➖ Removed Tests (1)

View removed tests
  • test_trace_decorator_no_trx
    • File: tests.tracing.test_decorator

All tests are passing successfully.

✅ Patch coverage is 100.00%. Project has 2508 uncovered lines.
✅ Project coverage is 89.99%. Comparing base (base) to head (head).

Files with missing lines (6)
File Patch % Lines
sentry_sdk/integrations/aiohttp.py 100.00% ⚠️ 1 partials
sentry_sdk/integrations/boto3.py 100.00% ⚠️ 1 partials
sentry_sdk/integrations/httpx.py 100.00% ⚠️ 1 partials
sentry_sdk/integrations/httpx2.py 100.00% ⚠️ 1 partials
sentry_sdk/integrations/pyreqwest.py 100.00% ⚠️ 1 partials
sentry_sdk/tracing_utils.py 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    89.99%    89.99%        —%
==========================================
  Files          193       193         —
  Lines        24974     25047       +73
  Branches      9008      9036       +28
==========================================
+ Hits         22473     22539       +66
- Misses        2501      2508        +7
- Partials      1437      1443        +6

Generated by Codecov Action

@sentrivana
sentrivana marked this pull request as ready for review August 7, 2026 09:39
@sentrivana
sentrivana requested a review from a team as a code owner August 7, 2026 09:39
Comment on lines +142 to +146
SPANDATA.HTTP_FRAGMENT: parsed_url.fragment,
}
)
add_http_breadcrumb(rv.status_code, breadcrumb_data)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: In non-streaming mode, two identical breadcrumbs are created for each HTTP request: one by add_http_breadcrumb and another by maybe_create_breadcrumbs_from_span when the span finishes.
Severity: MEDIUM

Suggested Fix

The maybe_create_breadcrumbs_from_span function should be modified to avoid creating a breadcrumb if one has already been created for the same HTTP client operation. Alternatively, the explicit call to add_http_breadcrumb in the httpx integration could be made conditional, checking if a breadcrumb for the span already exists.

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/httpx.py#L142-L146

Potential issue: In non-streaming mode, the httpx integration creates two identical
breadcrumbs for each HTTP request. The request is wrapped in a `sentry_sdk.start_span`
with `op=OP.HTTP_CLIENT`. When this span finishes, `maybe_create_breadcrumbs_from_span`
is called, which unconditionally creates a breadcrumb. Immediately after, the new code
explicitly calls `add_http_breadcrumb`, resulting in a second, identical breadcrumb for
the same request. This leads to redundant data in Sentry events.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The function will be removed in part 2 (#7131). I'll merge part 2 into this PR before merging into master.

@cursor 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.

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit f6a9c0c. Configure here.

Comment thread sentry_sdk/tracing_utils.py
SPANDATA.HTTP_FRAGMENT: parsed_url.fragment,
}
)
add_http_breadcrumb(rv.status_code, breadcrumb_data)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Breadcrumb skipped when no span is created

Medium Severity

In span streaming mode with no active parent span, httpx, httpx2, aiohttp and boto3 return early before reaching the new breadcrumb code, so no HTTP breadcrumb is recorded at all. pyreqwest places the call after the span context manager and does record one, making behaviour inconsistent and leaving breadcrumbs still coupled to span creation, which is what this change aims to remove.

Additional Locations (2)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit f6a9c0c. Configure here.

@sentrivana
sentrivana marked this pull request as draft August 7, 2026 09:45
@sentrivana

Copy link
Copy Markdown
Contributor Author

Will split this up further. I also noticed additional problems with it

@sentrivana sentrivana closed this Aug 7, 2026
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.

1 participant