Skip to content

fix(span-first): Set user.ip_address on all streamed spans#6434

Draft
sentrivana wants to merge 2 commits into
masterfrom
ivana/attach-user-ip-address-to-all-spans
Draft

fix(span-first): Set user.ip_address on all streamed spans#6434
sentrivana wants to merge 2 commits into
masterfrom
ivana/attach-user-ip-address-to-all-spans

Conversation

@sentrivana
Copy link
Copy Markdown
Contributor

@sentrivana sentrivana commented May 28, 2026

user.ip_address should be attached to all spans as per https://develop.sentry.dev/sdk/telemetry/spans/span-protocol/#common-attribute-keys, not just segments.

Use SPANDATA.USER_IP_ADDRESS constant and set it via
sentry_sdk.get_isolation_scope().set_attribute() so the IP address
is available on all spans, not just the server root span.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 28, 2026

Codecov Results 📊

446 passed | Total: 446 | Pass Rate: 100% | Execution Time: 1m 36s

All tests are passing successfully.

❌ Patch coverage is 23.08%. Project has 15217 uncovered lines.

Files with missing lines (5)
File Patch % Lines
sentry_sdk/integrations/aiohttp.py 0.00% ⚠️ 4 Missing
sentry_sdk/integrations/sanic.py 0.00% ⚠️ 2 Missing
sentry_sdk/integrations/tornado.py 0.00% ⚠️ 2 Missing
sentry_sdk/integrations/_asgi_common.py 66.67% ⚠️ 1 Missing
sentry_sdk/integrations/wsgi.py 50.00% ⚠️ 1 Missing

Generated by Codecov Action

Add test_user_ip_address_on_all_spans to wsgi, asgi, aiohttp, tornado,
and sanic. Each test creates a child span and verifies user.ip_address
is present on both server and child spans when send_default_pii=True.

Fix tornado and sanic to set user.ip_address on the isolation scope
before the handler runs, so child spans inherit the attribute.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sentrivana sentrivana changed the title fix(span-first): Set user.ip_address on isolation scope instead of span attributes fix(span-first): Set user.ip_address on all streamed spans May 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant