Skip to content

fix(server-utils): Ensure all orchestrion instrumentation lazy registers#22518

Open
isaacs wants to merge 1 commit into
developfrom
isaacs/lazy-register-orchestrion
Open

fix(server-utils): Ensure all orchestrion instrumentation lazy registers#22518
isaacs wants to merge 1 commit into
developfrom
isaacs/lazy-register-orchestrion

Conversation

@isaacs

@isaacs isaacs commented Jul 23, 2026

Copy link
Copy Markdown
Member

This ports and refactors the intent of #22387, using the mechanisms landed on develop in #22094, rather than the mechanisms in #22386 which are similar in intent, but substantially different in implementation.

The difference from #22387 is entirely in the plumbing underneath the helper. The way that "is my module injected?" and "tell me when it gets injected" are answered, both now use the machinery that already landed.

Beyond that, the actual registration, event emitting, double-wrap guard, and integration refactoring, should all look very familiar.

Co-Authored-By: isaacs <i@izs.me>
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@isaacs
isaacs requested review from JPeer264 and mydea July 23, 2026 03:32
@isaacs
isaacs requested review from a team as code owners July 23, 2026 03:32

@cursor cursor Bot 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 3 potential issues.

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


// mongoose < 9.7 is covered by the orchestrion-injected channels.
subscribeOrchestrionMongooseChannels();
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Native DC paths never subscribe

High Severity

instrumentMongoose and instrumentMysql2 now run only after orchestrion reports those packages as injected, but native diagnostics_channel support (mongoose >= 9.7, mysql2 >= 3.20) is intentionally outside the transform ranges. Those versions never inject, so subscribeMongooseDiagnosticChannels / subscribeMysql2DiagnosticChannels never run and spans are lost. GraphQL/Vercel AI keep the native half on setupOnce separately; these two do not.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ae063db. Configure here.

asyncEnd: NOOP,
error: NOOP,
end: recordConnectionFromChannel,
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Connection observers wait on binding

Medium Severity

instrumentPostgresJs still documents that connection/execute/connect observers must subscribe immediately because factory-time Connection() can fire before tracing-channel binding exists, but the whole function is now invoked through invokeOrchestrionInstrumentation, which wraps it in waitForTracingChannelBinding. Those early connection events can be missed again.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ae063db. Configure here.

const INSTRUMENTED = Symbol.for('SentryOrchestrionInstrumented');

// oxlint-disable-next-line typescript/no-explicit-any
type InstrumentationFn = ((...args: any[]) => void) & { [INSTRUMENTED]?: boolean };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Unguarded any in helper type

Low Severity

InstrumentationFn uses any[] with only an oxlint disable and no comment explaining why a safer type is impossible, which violates the project PR review rule against new any usage without that justification.

Fix in Cursor Fix in Web

Triggered by project rule: PR Review Guidelines for Cursor Bot

Reviewed by Cursor Bugbot for commit ae063db. Configure here.

@github-actions

Copy link
Copy Markdown
Contributor

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 27.78 kB - -
@sentry/browser - with treeshaking flags 26.22 kB - -
@sentry/browser (incl. Tracing) 46.3 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.09 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.13 kB - -
@sentry/browser (incl. Tracing, Replay) 85.58 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.23 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.29 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.94 kB - -
@sentry/browser (incl. Feedback) 44.97 kB - -
@sentry/browser (incl. sendFeedback) 32.58 kB - -
@sentry/browser (incl. FeedbackAsync) 37.64 kB - -
@sentry/browser (incl. Metrics) 28.86 kB - -
@sentry/browser (incl. Logs) 29.09 kB - -
@sentry/browser (incl. Metrics & Logs) 29.79 kB - -
@sentry/react 29.57 kB - -
@sentry/react (incl. Tracing) 48.61 kB - -
@sentry/vue 33.21 kB - -
@sentry/vue (incl. Tracing) 48.26 kB - -
@sentry/svelte 27.8 kB - -
CDN Bundle 30.12 kB - -
CDN Bundle (incl. Tracing) 48.16 kB - -
CDN Bundle (incl. Logs, Metrics) 31.7 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.49 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.96 kB - -
CDN Bundle (incl. Tracing, Replay) 85.73 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.03 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.51 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.79 kB - -
CDN Bundle - uncompressed 89.75 kB - -
CDN Bundle (incl. Tracing) - uncompressed 144.85 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.47 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 148.83 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.23 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.09 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.06 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 277.79 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 281.75 kB - -
@sentry/nextjs (client) 51.11 kB - -
@sentry/sveltekit (client) 46.73 kB - -
@sentry/core/server 80.19 kB +0.07% +50 B 🔺
@sentry/core/browser 51.99 kB - -
@sentry/node 124.3 kB +0.03% +27 B 🔺
@sentry/node (incl. diagnostics channel injection) 149.97 kB +0.19% +273 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 70.03 kB - -
@sentry/node - without tracing 74.44 kB +0.01% +1 B 🔺
@sentry/aws-serverless 83.94 kB +0.03% +21 B 🔺
@sentry/cloudflare (withSentry) - minified 196.64 kB - -
@sentry/cloudflare (withSentry) 483.92 kB - -

View base workflow run

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.

2 participants