Skip to content

feat(core): Apply request data to segment spans in span streaming#20654

Draft
chargome wants to merge 6 commits intodevelopfrom
cg-req-data-integration-span-streaming
Draft

feat(core): Apply request data to segment spans in span streaming#20654
chargome wants to merge 6 commits intodevelopfrom
cg-req-data-integration-span-streaming

Conversation

@chargome
Copy link
Copy Markdown
Member

@chargome chargome commented May 4, 2026

Implements the span-streaming counterpart of the requestDataIntegration.processEvent hook.

Request data from the scope's sdkProcessingMetadata is mapped to span attributes following sentry-conventions, reusing httpHeadersToSpanAttributes for sensitivity filtering and gating IP extraction behind sendDefaultPii.

Note: The logic is also guarded by client.getIntegrationByName('RequestData') so users who opt out of the integration don't get request data on streamed spans either.

This approach was chosen over adding a processSegmentSpan hook to the integration because captureSpan is tree-shakeable for non-streaming users, keeping the request data code out of bundles that don't need it (see linked ticket).

Closes #20380

@chargome chargome self-assigned this May 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 26.3 kB - -
@sentry/browser - with treeshaking flags 24.78 kB - -
@sentry/browser (incl. Tracing) 44.17 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 46.39 kB - -
@sentry/browser (incl. Tracing, Profiling) 49.14 kB - -
@sentry/browser (incl. Tracing, Replay) 83.55 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 73.01 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 88.23 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 100.84 kB - -
@sentry/browser (incl. Feedback) 43.44 kB - -
@sentry/browser (incl. sendFeedback) 31.11 kB - -
@sentry/browser (incl. FeedbackAsync) 36.19 kB - -
@sentry/browser (incl. Metrics) 27.6 kB - -
@sentry/browser (incl. Logs) 27.73 kB - -
@sentry/browser (incl. Metrics & Logs) 28.43 kB - -
@sentry/react 28.04 kB - -
@sentry/react (incl. Tracing) 46.4 kB - -
@sentry/vue 31.18 kB - -
@sentry/vue (incl. Tracing) 46.02 kB - -
@sentry/svelte 26.32 kB - -
CDN Bundle 28.91 kB - -
CDN Bundle (incl. Tracing) 46.94 kB - -
CDN Bundle (incl. Logs, Metrics) 30.34 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 48.04 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 69.4 kB - -
CDN Bundle (incl. Tracing, Replay) 84.07 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 85.15 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 89.89 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 90.97 kB - -
CDN Bundle - uncompressed 84.88 kB - -
CDN Bundle (incl. Tracing) - uncompressed 140.44 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 89.08 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 143.9 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 212.99 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 258.24 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 261.69 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 271.94 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 275.38 kB - -
@sentry/nextjs (client) 48.9 kB - -
@sentry/sveltekit (client) 44.64 kB - -
@sentry/node-core 60.08 kB +0.47% +281 B 🔺
@sentry/node 163.67 kB +0.16% +249 B 🔺
@sentry/node - without tracing 73.08 kB +1.12% +808 B 🔺
@sentry/aws-serverless 107.25 kB +0.29% +307 B 🔺
@sentry/cloudflare (withSentry) - minified 167.91 kB +0.61% +1.01 kB 🔺
⛔️ @sentry/cloudflare (withSentry) (max: 423.94 kB) 424.43 kB +0.63% +2.64 kB 🔺

View base workflow run

@chargome chargome requested a review from nicohrubec May 4, 2026 15:00
@chargome chargome marked this pull request as ready for review May 4, 2026 15:00
@chargome chargome requested a review from a team as a code owner May 4, 2026 15:00
safeSetSpanJSONAttributes(segmentSpanJSON, headerAttributes);
}

if (normalizedRequest.cookies) {
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.

l: could this already be set via the headers? in that case could we skip this part here?

const { normalizedRequest, ipAddress } = scopeData.sdkProcessingMetadata;
const { sendDefaultPii } = client.getOptions();

if (normalizedRequest && client.getIntegrationByName('RequestData')) {
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.

m: this just checks whether the integration is present. do we also need to check the individual include options when setting the data so users can still disable stuff or does this work as is?

Comment thread packages/core/src/tracing/spans/captureSpan.ts Outdated
Copy link
Copy Markdown

@cursor cursor Bot left a comment

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 1 potential issue.

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

Comment thread packages/core/src/tracing/spans/requestData.ts Outdated
@chargome chargome marked this pull request as draft May 5, 2026 13:26
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.

Event processor migration: RequestData integration

3 participants