Skip to content

ref(aiohttp): Move crumbs to integration - #7135

Open
sentrivana wants to merge 26 commits into
masterfrom
ivana/move-http-crumbs-1
Open

ref(aiohttp): Move crumbs to integration#7135
sentrivana wants to merge 26 commits into
masterfrom
ivana/move-http-crumbs-1

Conversation

@sentrivana

@sentrivana sentrivana commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Description

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

👀 Best reviewed with Hide whitespace on.

This turned out to be a bigger change than expected:

  • Breadcrumb data should be on par with what we're sending now. When we were taking it from the span, we had all the data readily available when we needed to create the breadcrumb. When moving the logic to the integration, we now need to remember information from the start request hook because it's not available in the finish request hook, where we create the breadcrumb now. (We need to create the breadcrumb at the end, because it contains stuff like HTTP status code.)
  • Breadcrumb data should be subject to PII filtering from send_default_pii/data_collection. So e.g. if parts of the query have been redacted on a span, they should not appear verbatim in the breadcrumb.
  • Since the PII redacting logic is different between transaction-based tracing and span streaming, the existing crumb tests needed to test both paths, as well as different PII filtering settings.

Additionally:

  • Rename span on the aiohttp trace context to _sentry_span

Issues

Reminders

span: "Union[Span, StreamedSpan, None]"
if has_span_streaming_enabled(client.options):
if sentry_sdk.traces.get_current_span() is None:
span = None

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.

This had to be moved after the PII redaction, because even if we don't want to create a span, we do want to create a breadcrumb, and we need to apply the same PII redacting logic to breadcrumbs.

scope: "sentry_sdk.Scope", span: "sentry_sdk.tracing.Span"
) -> None:
if span.op == OP.HTTP_CLIENT:
if span.op == OP.HTTP_CLIENT and span.origin not in ("auto.http.aiohttp",):

@sentrivana sentrivana Aug 7, 2026

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.

This is just here to make sure we're not creating breadcrumbs the old way in transaction-based tracing anymore. Once all HTTP client integrations have been migrated, the whole function will go away

Base automatically changed from ivana/move-redis-breadcrumbs-to-integration to master August 7, 2026 11:33
@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Codecov Results 📊

104314 passed | ⏭️ 6677 skipped | Total: 110991 | Pass Rate: 93.98% | Execution Time: 363m 51s

📊 Comparison with Base Branch

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

All tests are passing successfully.

✅ Patch coverage is 89.09%. Project has 2478 uncovered lines.
✅ Project coverage is 90.16%. Comparing base (base) to head (head).

Files with missing lines (2)
File Patch % Lines
sentry_sdk/integrations/aiohttp.py 86.05% ⚠️ 6 Missing and 4 partials
sentry_sdk/tracing_utils.py 100.00% ⚠️ 1 partials
Coverage diff
@@            Coverage Diff             @@
##          main       #PR       +/-##
==========================================
+ Coverage    90.15%    90.16%    +0.01%
==========================================
  Files          193       193         —
  Lines        25147     25171       +24
  Branches      9136      9146       +10
==========================================
+ Hits         22669     22693       +24
- Misses        2478      2478         —
- Partials      1431      1429        -2

Generated by Codecov Action

@sentrivana
sentrivana marked this pull request as ready for review August 7, 2026 11:44
@sentrivana
sentrivana requested a review from a team as a code owner August 7, 2026 11:44
Comment thread sentry_sdk/integrations/aiohttp.py Outdated
Comment thread sentry_sdk/integrations/aiohttp.py Outdated
@sentrivana
sentrivana marked this pull request as draft August 7, 2026 12:17
@sentrivana
sentrivana marked this pull request as ready for review August 7, 2026 12:38
Comment thread sentry_sdk/integrations/aiohttp.py Outdated

@ericapisani ericapisani left a comment

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.

Non-blocking question, otherwise LGTM 🚀

Comment thread sentry_sdk/tracing_utils.py Outdated
Comment on lines 461 to +469
legacy_span.set_data("url", parsed_url.url)
legacy_span.set_data(SPANDATA.HTTP_QUERY, parsed_url.query)
legacy_span.set_data(SPANDATA.HTTP_FRAGMENT, parsed_url.fragment)
breadcrumb.update(
{
SPANDATA.HTTP_QUERY: parsed_url.query,
SPANDATA.HTTP_FRAGMENT: parsed_url.fragment,
"url": parsed_url.url,
}

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.

Legacy span path leaks unfiltered URL data into breadcrumbs

In the legacy span else: block, raw parsed_url.query and parsed_url.fragment are added to the breadcrumb unconditionally, bypassing should_send_default_pii/data_collection checks that the streaming path correctly applies.

Evidence
  • The streaming span branch (lines 401–447) only adds query/fragment to breadcrumb when has_data_collection_enabled or should_send_default_pii() is true.
  • The legacy else: branch at line 460 adds breadcrumb.update(...) inside if parsed_url is not None: with no PII guard at all.
  • Since maybe_create_breadcrumbs_from_span previously excluded auto.http.aiohttp, no breadcrumb was ever created for aiohttp; this PR adds breadcrumbs directly in the integration, meaning the unfiltered legacy path now leaks raw query strings to breadcrumbs.
  • The PR description explicitly requires breadcrumb data to be subject to PPI filtering, which the legacy path violates.

Identified by Warden · find-bugs · ZL9-MZY

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