Skip to content

fix(core): Set conversation_id only on gen_ai spans#20274

Merged
nicohrubec merged 4 commits intodevelopfrom
nh/conversation-id-only-on-genai-spans
Apr 14, 2026
Merged

fix(core): Set conversation_id only on gen_ai spans#20274
nicohrubec merged 4 commits intodevelopfrom
nh/conversation-id-only-on-genai-spans

Conversation

@nicohrubec
Copy link
Copy Markdown
Member

@nicohrubec nicohrubec commented Apr 14, 2026

We should only set the conversation_id for gen_ai spans. These are the only spans for which this attribute is relevant and setting it on other spans can lead to unnecessarily slow queries in the product.

This works fine for all our AI integrations except Vercel. This is because the Vercel ai integration also registers a spanStart hook that transforms Vercel spans to sentry gen_ai spans. The conversation id integration fires before that happens, so we have to special case the Vercel ai spans here for this to work properly.

Closes #20272

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

Semver Impact of This PR

🟢 Patch (bug fixes)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

Cloudflare

  • Split alarms into multiple traces and link them by JPeer264 in #19373
  • Propagate traceparent to RPC calls - via fetch by JPeer264 in #19991

Core

  • Automatically disable truncation when span streaming is enabled in LangGraph integration by andreiborza in #20231
  • Automatically disable truncation when span streaming is enabled in LangChain integration by andreiborza in #20230
  • Automatically disable truncation when span streaming is enabled in Google GenAI integration by andreiborza in #20229
  • Automatically disable truncation when span streaming is enabled in Anthropic AI integration by andreiborza in #20228
  • Automatically disable truncation when span streaming is enabled in Vercel AI integration by andreiborza in #20232
  • Automatically disable truncation when span streaming is enabled in OpenAI integration by andreiborza in #20227
  • Add enableTruncation option to Vercel AI integration by nicohrubec in #20195
  • Add enableTruncation option to Google GenAI integration by andreiborza in #20184
  • Add enableTruncation option to Anthropic AI integration by andreiborza in #20181
  • Add enableTruncation option to LangGraph integration by andreiborza in #20183
  • Add enableTruncation option to LangChain integration by andreiborza in #20182
  • Add enableTruncation option to OpenAI integration by andreiborza in #20167
  • Export a reusable function to add tracing headers by JPeer264 in #20076

Deps

  • Bump axios from 1.13.5 to 1.15.0 by dependabot in #20180
  • Bump hono from 4.12.7 to 4.12.12 by dependabot in #20118
  • Bump defu from 6.1.4 to 6.1.6 by dependabot in #20104

Other

  • (browser) Add View Hierarchy integration by timfish in #14981
  • (cloudflare,deno,vercel-edge) Add span streaming support by Lms24 in #20127
  • (node) Include global scope for eventLoopBlockIntegration by timfish in #20108
  • (node-native) Add support for V8 v14 (Node v25+) by timfish in #20125
  • (opentelemetry) Vendor AsyncLocalStorageContextManager by mydea in #20243

Bug Fixes 🐛

Deno

  • Handle reader.closed rejection from releaseLock() in streaming by andreiborza in #20187
  • Avoid inferring invalid span op from Deno tracer by Lms24 in #20128

Other

  • (ci) Prevent command injection in ci-metadata workflow by fix-it-felix-sentry in #19899
  • (core) Set conversation_id only on gen_ai spans by nicohrubec in #20274
  • (core, node) Support loading Express options lazily by isaacs in #20211
  • (e2e) Add op check to waitForTransaction in React Router e2e tests by copilot-swe-agent in #20193
  • (e2e-tests) Remove flaky navigation breadcrumb assertions from parameterized-routes tests by copilot-swe-agent in #20202
  • (node-integration-tests) Fix flaky kafkajs test race condition by copilot-swe-agent in #20189

Internal Changes 🔧

Ci

  • Remove node-overhead GitHub Action by mydea in #20246
  • Bump dorny/paths-filter from v3.0.1 to v4.0.1 by mydea in #20251
  • Remove codecov steps from jobs that produce no coverage/JUnit data by mydea in #20244

Deps

  • Bump hono from 4.12.7 to 4.12.12 in /dev-packages/e2e-tests/test-applications/cloudflare-hono by dependabot in #20119
  • Bump axios from 1.13.5 to 1.15.0 in /dev-packages/e2e-tests/test-applications/nestjs-basic by dependabot in #20179

Deps Dev

  • Bump @sveltejs/kit from 2.53.3 to 2.57.1 by dependabot in #20216
  • Bump vite from 7.2.0 to 7.3.2 in /dev-packages/e2e-tests/test-applications/tanstackstart-react by dependabot in #20107

Other

  • (bugbot) Add rules to flag test-flake-provoking patterns by Lms24 in #20192
  • (react) Remove duplicated test mock by s1gr1d in #20200
  • (size-limit) Bump failing size limit scenario by Lms24 in #20186
  • Add PR review reminder workflow by copilot-swe-agent in #20175
  • Fix lint warnings by mydea in #20250
  • Fix flaky ANR test by increasing blocking duration by JPeer264 in #20239
  • Add automatic flaky test detector by nicohrubec in #18684

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 14, 2026

size-limit report 📦

Path Size % Change Change
@sentry/browser 25.78 kB +0.22% +56 B 🔺
@sentry/browser - with treeshaking flags 24.27 kB +0.23% +55 B 🔺
@sentry/browser (incl. Tracing) 42.77 kB +0.11% +45 B 🔺
@sentry/browser (incl. Tracing, Profiling) 47.4 kB +0.11% +49 B 🔺
@sentry/browser (incl. Tracing, Replay) 81.58 kB +0.07% +50 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 71.14 kB +0.05% +34 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 86.28 kB +0.06% +47 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 98.49 kB +0.05% +49 B 🔺
@sentry/browser (incl. Feedback) 42.59 kB +0.17% +71 B 🔺
@sentry/browser (incl. sendFeedback) 30.45 kB +0.21% +61 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.45 kB +0.19% +66 B 🔺
@sentry/browser (incl. Metrics) 27.07 kB +0.13% +34 B 🔺
@sentry/browser (incl. Logs) 27.2 kB +0.06% +16 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.89 kB +0.13% +34 B 🔺
@sentry/react 27.53 kB +0.17% +46 B 🔺
@sentry/react (incl. Tracing) 45.09 kB +0.1% +45 B 🔺
@sentry/vue 30.61 kB +0.15% +44 B 🔺
@sentry/vue (incl. Tracing) 44.63 kB +0.1% +41 B 🔺
@sentry/svelte 25.8 kB +0.24% +60 B 🔺
CDN Bundle 28.46 kB +0.17% +48 B 🔺
CDN Bundle (incl. Tracing) 43.8 kB +0.11% +45 B 🔺
CDN Bundle (incl. Logs, Metrics) 29.83 kB +0.16% +46 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 44.88 kB +0.11% +46 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.65 kB +0.07% +48 B 🔺
CDN Bundle (incl. Tracing, Replay) 80.68 kB +0.07% +49 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81.71 kB +0.07% +52 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 86.21 kB +0.06% +45 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 87.24 kB +0.06% +47 B 🔺
CDN Bundle - uncompressed 83.12 kB +0.15% +124 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 129.92 kB +0.1% +124 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 87.27 kB +0.15% +124 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 133.33 kB +0.1% +124 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 210.25 kB +0.06% +124 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 246.79 kB +0.06% +124 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 250.19 kB +0.05% +124 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 259.71 kB +0.05% +124 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 263.09 kB +0.05% +124 B 🔺
@sentry/nextjs (client) 47.52 kB +0.1% +44 B 🔺
@sentry/sveltekit (client) 43.24 kB +0.12% +48 B 🔺
@sentry/node-core 57.94 kB +0.15% +83 B 🔺
@sentry/node 174.9 kB +0.07% +111 B 🔺
@sentry/node - without tracing 97.8 kB +0.18% +175 B 🔺
@sentry/aws-serverless 115.06 kB +0.08% +84 B 🔺

View base workflow run

@nicohrubec nicohrubec requested review from andreiborza and mydea April 14, 2026 09:40
@nicohrubec nicohrubec marked this pull request as ready for review April 14, 2026 09:40
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 81df583. Configure here.

// Only apply conversation ID to gen_ai spans
if (!spanToJSON(span).op?.startsWith('gen_ai.')) {
return;
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Conversation ID skipped for Vercel AI spans due to hook ordering

High Severity

The spanToJSON(span).op check will always fail for Vercel AI spans because the gen_ai.* op is set by the Vercel AI integration's own spanStart handler (onVercelAiSpanStart), which is registered after the conversationIdIntegration handler. Since conversationIdIntegration uses setup() and is a default integration, while Vercel AI registers its handler in afterAllSetup() (Node) or later in setup() order (Cloudflare), the conversation ID handler always runs first — when op is still undefined. This means conversation_id will never be applied to Vercel AI gen_ai spans, which is a regression from the previous behavior.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 81df583. Configure here.

@nicohrubec nicohrubec marked this pull request as draft April 14, 2026 12:42
@nicohrubec nicohrubec requested a review from Lms24 April 14, 2026 13:12
@nicohrubec nicohrubec marked this pull request as ready for review April 14, 2026 13:28
Copy link
Copy Markdown
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

LGTM for now. To avoid the problem of spanStart order with vercel AI, we could also think about using something like the processSpan hook in the future (this is only scoped to span streaming for now but we could think about alternatives). At this point, the op is already there and we already converted the span to JSON. Meaning, we can avoid the performance overhead of the spanToJSON call. No need to do this right now, just a thought.

(we could also use an event processor and modify the child spans of a transaction but given span streaming, I'd rather avoid this for the moment xD)

@nicohrubec
Copy link
Copy Markdown
Member Author

@Lms24 Good to know thanks! Maybe we can revisit this after we have fully adopted span streaming

@nicohrubec nicohrubec merged commit 7284606 into develop Apr 14, 2026
464 of 474 checks passed
@nicohrubec nicohrubec deleted the nh/conversation-id-only-on-genai-spans branch April 14, 2026 17:16
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.

Set conversation id only for gen_ai spans

2 participants