Skip to content

fix(core): Only attach flags context to error events#20116

Merged
Lms24 merged 2 commits intodevelopfrom
lms/fix-core-feature-flag-evt-processor
Apr 8, 2026
Merged

fix(core): Only attach flags context to error events#20116
Lms24 merged 2 commits intodevelopfrom
lms/fix-core-feature-flag-evt-processor

Conversation

@Lms24
Copy link
Copy Markdown
Member

@Lms24 Lms24 commented Apr 7, 2026

While looking into feature flags for span streaming, we noticed that the SDK currently attaches the flags context to all outgoing event types, including transactions (h/t @mjq). The develop spec specifies that feature flags should be added to

  • errors via the flags context
  • spans via span attributes

This PR ensures that the event processor adding the context is scoped to error events only.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 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 ✨

Core

  • Support registerTool/registerResource/registerPrompt in MCP integration by betegon in #20071
  • Support embeddings in langchain by nicohrubec in #20017

Deps

  • Bump lodash.template from 4.5.0 to 4.18.1 by dependabot in #20085
  • Bump @xmldom/xmldom from 0.8.3 to 0.8.12 by dependabot in #20066

Other

  • (cloudflare) Support basic WorkerEntrypoint by JPeer264 in #19884
  • (core, node) Portable Express integration by isaacs in #19928
  • (deno) Add denoRuntimeMetricsIntegration by chargome in #20023
  • (node, bun) Enforce minimum collection interval in runtime metrics integrations by chargome in #20068

Bug Fixes 🐛

Core

  • Only attach flags context to error events by Lms24 in #20116
  • Replace regex with string check in stack parser to prevent main thread blocking by chargome in #20089
  • Set span.status to error when MCP tool returns JSON-RPC error response by betegon in #20082

Other

  • (aws-serverless) Add timeout to _endSpan forceFlush to prevent Lambda hanging by logaretm in #20064
  • (cloudflare) Ensure every request instruments functions by JPeer264 in #20044
  • (gatsby) Fix errorHandler signature to match bundler-plugin-core API by JPeer264 in #20048

Internal Changes 🔧

Core

  • Do not emit spans for chats.create in google-genai by nicohrubec in #19990
  • Unify .do* span ops to gen_ai.generate_content by nicohrubec in #20074
  • Simplify addResponseAttributes in openai integration by nicohrubec in #20013
  • Extract shared endStreamSpan for AI integrations by nicohrubec in #20021
  • Remove provider-specific AI span attributes in favor of gen_ai attributes in sentry conventions by nicohrubec in #20011

Deps

  • Bump mshick/add-pr-comment from dd126dd8c253650d181ad9538d8b4fa218fc31e8 to e7516d74559b5514092f5b096ed29a629a1237c6 by dependabot in #20078
  • Bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.24.1 to 2.25.2 by dependabot in #20081

Other

  • (node) Add node integration tests for Vercel ToolLoopAgent by nicohrubec in #20087
  • (nuxt) Make Nuxt 5 (nightly) E2E optional by s1gr1d in #20113
  • (oxlint) Add typeawareness into oxlintrc by JPeer264 in #20075
  • Update validate-pr workflow by stephanie-anderson in #20072
  • Remove unused tsconfig-template folder by mydea in #20067

🤖 This preview updates automatically when you update the PR.

@Lms24 Lms24 self-assigned this Apr 7, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

size-limit report 📦

⚠️ Warning: Base artifact is not the latest one, because the latest workflow run is not done yet. This may lead to incorrect results. Try to re-run all tests to get up to date results.

Path Size % Change Change
@sentry/browser 25.64 kB +0.01% +2 B 🔺
@sentry/browser - with treeshaking flags 24.13 kB - -
@sentry/browser (incl. Tracing) 42.15 kB +0.01% +3 B 🔺
@sentry/browser (incl. Tracing, Profiling) 46.77 kB +0.01% +4 B 🔺
@sentry/browser (incl. Tracing, Replay) 80.94 kB +0.01% +1 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 70.56 kB +0.01% +1 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 85.65 kB +0.01% +3 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 97.91 kB +0.01% +2 B 🔺
@sentry/browser (incl. Feedback) 42.42 kB +0.01% +4 B 🔺
@sentry/browser (incl. sendFeedback) 30.31 kB +0.02% +4 B 🔺
@sentry/browser (incl. FeedbackAsync) 35.3 kB +0.05% +15 B 🔺
@sentry/browser (incl. Metrics) 26.95 kB +0.01% +2 B 🔺
@sentry/browser (incl. Logs) 27.1 kB +0.01% +2 B 🔺
@sentry/browser (incl. Metrics & Logs) 27.78 kB +0.02% +3 B 🔺
@sentry/react 27.41 kB +0.02% +3 B 🔺
@sentry/react (incl. Tracing) 44.48 kB +0.01% +3 B 🔺
@sentry/vue 30.08 kB +0.01% +1 B 🔺
@sentry/vue (incl. Tracing) 44.05 kB +0.01% +3 B 🔺
@sentry/svelte 25.67 kB +0.01% +2 B 🔺
CDN Bundle 28.32 kB +0.04% +10 B 🔺
CDN Bundle (incl. Tracing) 43.12 kB +0.05% +21 B 🔺
CDN Bundle (incl. Logs, Metrics) 29.69 kB +0.04% +11 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) 44.17 kB +0.04% +15 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) 68.49 kB +0.02% +13 B 🔺
CDN Bundle (incl. Tracing, Replay) 80.01 kB +0.02% +15 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 81.06 kB +0.02% +13 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 85.55 kB +0.02% +11 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 86.59 kB +0.02% +12 B 🔺
CDN Bundle - uncompressed 82.72 kB +0.07% +54 B 🔺
CDN Bundle (incl. Tracing) - uncompressed 127.86 kB +0.05% +54 B 🔺
CDN Bundle (incl. Logs, Metrics) - uncompressed 86.86 kB +0.07% +54 B 🔺
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 131.27 kB +0.05% +54 B 🔺
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 209.84 kB +0.03% +54 B 🔺
CDN Bundle (incl. Tracing, Replay) - uncompressed 244.74 kB +0.03% +54 B 🔺
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 248.13 kB +0.03% +54 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 257.65 kB +0.03% +54 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 261.04 kB +0.03% +54 B 🔺
@sentry/nextjs (client) 46.89 kB +0.01% +4 B 🔺
@sentry/sveltekit (client) 42.62 kB +0.01% +3 B 🔺
@sentry/node-core 55.76 kB +0.03% +12 B 🔺
@sentry/node 172.41 kB -0.2% -341 B 🔽
@sentry/node - without tracing 96.05 kB +0.04% +38 B 🔺
@sentry/aws-serverless 112.85 kB +0.07% +76 B 🔺

View base workflow run

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

node-overhead report 🧳

Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.

Scenario Requests/s % of Baseline Prev. Requests/s Change %
GET Baseline 11,368 - 10,732 +6%
GET With Sentry 2,107 19% 2,061 +2%
GET With Sentry (error only) 7,887 69% 7,531 +5%
POST Baseline 1,207 - 1,267 -5%
POST With Sentry 630 52% 622 +1%
POST With Sentry (error only) 1,050 87% 1,109 -5%
MYSQL Baseline 3,964 - 3,467 +14%
MYSQL With Sentry 574 14% 449 +28%
MYSQL With Sentry (error only) 3,180 80% 2,901 +10%

View base workflow run

@Lms24 Lms24 marked this pull request as ready for review April 8, 2026 08:40
@Lms24 Lms24 requested review from a team, logaretm and s1gr1d and removed request for a team April 8, 2026 08:41
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 prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Error event test doesn't verify flags were copied
    • Added proper assertion to verify event.contexts.flags contains the expected flags instead of just checking reference equality.

Create PR

Or push these changes by commenting:

@cursor push 223cf450c5
Preview (223cf450c5)
diff --git a/packages/core/test/lib/utils/featureFlags.test.ts b/packages/core/test/lib/utils/featureFlags.test.ts
--- a/packages/core/test/lib/utils/featureFlags.test.ts
+++ b/packages/core/test/lib/utils/featureFlags.test.ts
@@ -164,8 +164,13 @@
 
       const result = _INTERNAL_copyFlagsFromScopeToEvent(event);
 
-      expect(result).toEqual(event);
       expect(getCurrentScope).toHaveBeenCalled();
+      expect(result.contexts?.flags).toEqual({
+        values: [
+          { flag: 'feat1', result: true },
+          { flag: 'feat2', result: false },
+        ],
+      });
     });
   });
 });

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 53e6de3. Configure here.

@Lms24 Lms24 enabled auto-merge (squash) April 8, 2026 16:04
@Lms24 Lms24 merged commit 7c19325 into develop Apr 8, 2026
472 of 476 checks passed
@Lms24 Lms24 deleted the lms/fix-core-feature-flag-evt-processor branch April 8, 2026 16:15
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.

3 participants