Skip to content

feat(node): Always set up express, fastify, koa, hapi integrations - #23473

Merged
mydea merged 18 commits into
developfrom
fn/default-framework-integrations
Aug 25, 2026
Merged

feat(node): Always set up express, fastify, koa, hapi integrations#23473
mydea merged 18 commits into
developfrom
fn/default-framework-integrations

Conversation

@mydea

@mydeamydea commented Aug 21, 2026

Copy link
Copy Markdown
Member

These integrations may also do non-tracing related things (e.g. error capturing etc), so they should be added by default.
This also means that we always want to add the orchestrion runtime, even in non-tracing mode.

Instead, I added a flag enableRuntimeChannelInjection to opt-out of this behavior if needed.

Also added these three as defaults to deno and bun, to mirror this.

Additionally, this unifies the integrations we add into getErrorIntegrations() and getTracingIntegrations(), so we can re-use this in node, deno and bun. It also adds awsIntegration to the tracing set so this is also added in all scenarios now.

@mydeamydea self-assigned this Aug 21, 2026
Comment threadpackages/node/src/integrations/tracing/index.ts
Comment threadpackages/node/test/sdk/diagnosticsChannelInjection.test.ts
@github-actions

github-actionsBot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser28.57 kB--
@sentry/browser - with treeshaking flags26.92 kB--
@sentry/browser - with treeshaking flags tracing without tracing26.82 kB--
@sentry/browser (incl. Tracing)48.37 kB--
@sentry/browser (incl. Tracing + Span Streaming)48.39 kB--
@sentry/browser (incl. Tracing, Profiling)51.27 kB--
@sentry/browser (incl. Tracing, Replay)87.77 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags77.23 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)92.47 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)105.14 kB--
@sentry/browser (incl. Feedback)45.81 kB--
@sentry/browser (incl. sendFeedback)33.36 kB--
@sentry/browser (incl. FeedbackAsync)38.47 kB--
@sentry/browser (incl. Metrics)29.52 kB--
@sentry/browser (incl. Logs)29.8 kB--
@sentry/browser (incl. Metrics & Logs)30.45 kB--
@sentry/react30.33 kB--
@sentry/react (incl. Tracing)50.56 kB--
@sentry/vue35.41 kB--
@sentry/vue (incl. Tracing)50.37 kB--
@sentry/svelte28.6 kB--
CDN Bundle30.32 kB--
CDN Bundle (incl. Tracing)48.9 kB--
CDN Bundle (incl. Logs, Metrics)32.54 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)50.78 kB--
CDN Bundle (incl. Replay, Logs, Metrics)72.91 kB--
CDN Bundle (incl. Tracing, Replay)86.35 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)88.19 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)92.09 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)94.04 kB--
CDN Bundle - uncompressed89.94 kB--
CDN Bundle (incl. Tracing) - uncompressed146.25 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed96.23 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed151.94 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed225.18 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed265.52 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed271.2 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed279.22 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed284.89 kB--
@sentry/nextjs (client)53.12 kB--
@sentry/sveltekit (client)48.8 kB--
@sentry/core/server64.95 kB--
@sentry/core/browser52.11 kB--
@sentry/node121.61 kB+3.48%+4.09 kB 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection)85.18 kB--
@sentry/node - without tracing87.43 kB+6.56%+5.38 kB 🔺
@sentry/aws-serverless95.81 kB+4.73%+4.32 kB 🔺
@sentry/cloudflare (withSentry) - minified196.3 kB--
@sentry/cloudflare (withSentry)485.93 kB--

View base workflow run

Comment threadpackages/deno/src/sdk.ts Outdated
@mydea
mydea marked this pull request as ready for review August 24, 2026 08:59
@mydea
mydea requested review from a team as code ownersAugust 24, 2026 08:59
@mydea
mydea requested review from JPeer264, andreiborza, isaacs and nicohrubec and removed request for a teamAugust 24, 2026 08:59
@mydea
mydeaforce-pushed the fn/default-framework-integrations branch from 7c5156c to dee852fCompareAugust 24, 2026 11:06
Comment threadpackages/node/src/sdk/index.ts
@mydea
mydeaforce-pushed the fn/default-framework-integrations branch from 3e1ee6e to 20ff2d2CompareAugust 24, 2026 11:24

@isaacsisaacs 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.

This is a good fix to the main issue raised in the fastify PR.

Only a few small suggestions in the code here, but the bigger issue is that even with this, 3 of the 4 mentioned integrations actually still don't do anything if tracing is disabled, because they gate on getActiveSpan() !== undefined.

That could of course be done in a followup, but we may as well do it now. Here's a patch that would close the loop on it: https://gist.github.com/isaacs/c79cb5d86b5c63431a2442dbbf0ae2ee

Comment threadpackages/node/src/sdk/index.ts Outdated
Comment on lines 224 to 226

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.

Not changed in this PR, but I think we still want this detection to happen, especially now that we're relying on it for error handling and transaction names. The docs for the option say that you should set it false if you have orchestrion in the bundle, but the detection is for either bundle or runtime injection, so it's valuable to keep.

Suggested change
detectOrchestrionSetup();

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

right, makes sense 👍

Comment threadpackages/bun/src/sdk.ts Outdated
Comment threadpackages/node/src/sdk/index.ts Outdated
Comment on lines +73 to +77
// Framework-level integrations
expressIntegration(),
fastifyIntegration(),
hapiIntegration(),
koaIntegration(),

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.

These four show up in a few places now:

  • here (packages/node/src/sdk/index.ts)
  • packages/bun/src/sdk.ts
  • packages/deno/src/sdk.ts

I fee like this is prone to overlooking, if we add another framework that belongs to this set. Could it live in a list somewhere centrally reusable?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

moved this to a helper exported from server-utils which all of these use!

};
}

export interface ErrorSink {

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.

This looks like a copy-paste of TransactionSink above it. Could we abstract them both in to a function makeSink<T>(): { record(e: T): null; waitFor(p): Promise<T> } reusable?

It's a test, so not super high priority, but could be a bit less to look at.

Comment on lines +27 to +30
// The following integrations are not considered performance integrations because they are "framework"-level
// meaning they may also handle error capture and similar things.
// Thus, we add them by default:
// express, fastify, hapi, koa

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.

I feel like this comment is weirdly placed. Shouldn't it be at packages/node/src/sdk/index.ts line 73, or wherever the integrations ultimately get moved to?

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

hmm the idea was to make it clear right here why these are not in this list. but maybe it is unnecessary and we just remove the comment overall, it should be possible to figure this out looking at the code of default integrations anyhow 😅

@mydea
mydeaforce-pushed the fn/default-framework-integrations branch from 20ff2d2 to 7020156CompareAugust 25, 2026 08:12
Comment threadpackages/deno/src/sdk.ts
Comment threaddev-packages/deno-integration-tests/src/index.ts
Comment threadpackages/node/test/sdk/diagnosticsChannelInjection.test.ts
Comment threadpackages/deno/src/sdk.ts
mydeaand others added 7 commits August 25, 2026 13:11
Mirror the Node SDK change promoting the framework integrations (express, fastify, hapi, koa)
to always-on defaults. Bun gains all four; Deno (which already listed express, hapi, koa)
gains fastify, now also re-exported from `@sentry/server-utils/orchestrion`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Mirror the other orchestrion Deno suites: assert the Fastify integration is in the defaults and that
the native `tracing:fastify.request.handler:error` channel captures the error (with mechanism
`auto.function.fastify`). Adds a shared `errorSink` helper alongside `transactionSink`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea
mydeaforce-pushed the fn/default-framework-integrations branch from 081f193 to ee17f3dCompareAugust 25, 2026 11:22

@cursorcursorBot left a comment

Copy link
Copy Markdown

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

prismaIntegration,
amqplibIntegration,
anthropicAIIntegration,
expressIntegration,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Public helper drops framework integrations

Medium Severity

getAutoPerformanceIntegrations is still a public @sentry/node export, but it now only returns getTracingIntegrations(), so callers no longer receive express, fastify, hapi, or koa. Those moved to getErrorIntegrations, which @sentry/node does not re-export, so there is no documented replacement for the previous full set. This is a public API behavior change without a deprecation notice.

Additional Locations (1)
Fix in CursorFix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit ee17f3d. Configure here.

@mydea
mydea merged commit d410f29 into developAug 25, 2026
273 checks passed
@mydea
mydea deleted the fn/default-framework-integrations branch August 25, 2026 12:00
mydea added a commit that referenced this pull request Aug 27, 2026
)
Stacked on #23473.
Adds a build-time opt-out for the Node SDK's runtime diagnostics-channel
injection, complementing the runtime `enableRuntimeChannelInjection`
option from the base PR.
- New `__SENTRY_CHANNEL_INJECTION__` treeshaking flag, mirroring
`__SENTRY_TRACING__`: when a bundler text-replaces it with `false`, the
`registerDiagnosticsChannelInjection()` / `detectOrchestrionSetup()`
block in `init` is dropped, and its transitive orchestrion-register code
tree-shakes away.
- Exposed through the bundler plugins'
`bundleSizeOptimizations.excludeChannelInjection`, which maps to
`__SENTRY_CHANNEL_INJECTION__ = false` via the same mechanism as
`excludeTracing`.
- The gate now reads both the build flag and the runtime option:
`(typeof __SENTRY_CHANNEL_INJECTION__ === 'undefined' ||
__SENTRY_CHANNEL_INJECTION__) && options.enableRuntimeChannelInjection
!== false`.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-authored-by: isaacs <i@izs.me>
Sign up for freeto 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

@mydea@isaacs