Skip to content

feat(remix): Add orchestrion-based remix instrumentation#22244

Open
mydea wants to merge 9 commits into
developfrom
francesconovy/js-2483-rewrite-remixinstrumentation-to-orchestrion
Open

feat(remix): Add orchestrion-based remix instrumentation#22244
mydea wants to merge 9 commits into
developfrom
francesconovy/js-2483-rewrite-remixinstrumentation-to-orchestrion

Conversation

@mydea

@mydea mydea commented Jul 14, 2026

Copy link
Copy Markdown
Member

Rewrites the vendored RemixInstrumentation (an OpenTelemetry InstrumentationBase that patched @remix-run/server-runtime) to a diagnostics-channel listener, with orchestrion injecting the channels into the instrumented module at build time.

SDK changes

  • @sentry/server-utils — populated the orchestrion config for @remix-run/server-runtime (orchestrion/config/remix.ts)
  • @sentry/remix — adjusted the remixIntegration so it runs either OTEL-based instrumentation, or prchestrion-based instrumentation if opted in.

E2E changes

  • Folded the standalone remix-orchestrion test app into create-remix-app-v2 as an INJECT_ORCHESTRION-gated sentryTest variant, so one codebase runs both the OpenTelemetry and orchestrion paths (build-time injection via the orchestrion Vite plugin, DB routes + docker for mysql/ioredis, and a build-injection assertion). The base transaction tests run in both variants as a parity check.
  • To make @remix-run/server-runtime reachable by the build-time transform, @remix-run/node is force-bundled (it re-exports server-runtime, which otherwise stays external and is loaded by remix-serve at runtime, outside the Vite bundle).

Fixes #20910

@linear-code

linear-code Bot commented Jul 14, 2026

Copy link
Copy Markdown

JS-2483

Comment thread packages/remix/src/server/integrations/tracing-channel.ts
Comment thread packages/remix/src/server/integrations/tracing-channel.ts Outdated
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.65 kB - -
@sentry/browser - with treeshaking flags 26.09 kB - -
@sentry/browser (incl. Tracing) 46.41 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.2 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.19 kB - -
@sentry/browser (incl. Tracing, Replay) 85.67 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.3 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 90.38 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 103.04 kB - -
@sentry/browser (incl. Feedback) 44.83 kB - -
@sentry/browser (incl. sendFeedback) 32.45 kB - -
@sentry/browser (incl. FeedbackAsync) 37.57 kB - -
@sentry/browser (incl. Metrics) 28.73 kB - -
@sentry/browser (incl. Logs) 28.97 kB - -
@sentry/browser (incl. Metrics & Logs) 29.66 kB - -
@sentry/react 29.45 kB - -
@sentry/react (incl. Tracing) 48.67 kB - -
@sentry/vue 33.08 kB - -
@sentry/vue (incl. Tracing) 48.39 kB - -
@sentry/svelte 27.67 kB - -
CDN Bundle 30.05 kB - -
CDN Bundle (incl. Tracing) 48.4 kB - -
CDN Bundle (incl. Logs, Metrics) 31.63 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.7 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.86 kB - -
CDN Bundle (incl. Tracing, Replay) 85.89 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.21 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.69 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.96 kB - -
CDN Bundle - uncompressed 89.58 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.32 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.28 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.3 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.01 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.53 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.49 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.23 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.18 kB - -
@sentry/nextjs (client) 51.22 kB - -
@sentry/sveltekit (client) 46.86 kB - -
@sentry/core/server 78.5 kB - -
@sentry/core/browser 64.85 kB - -
@sentry/node-core 62.79 kB - -
@sentry/node 125.2 kB +0.01% +1 B 🔺
@sentry/node (incl. diagnostics channel injection) 140.44 kB +0.16% +215 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.96 kB - -
@sentry/node/light 50.79 kB -0.01% -1 B 🔽
@sentry/node - without tracing 74.17 kB -0.01% -1 B 🔽
@sentry/aws-serverless 83.38 kB -0.01% -2 B 🔽
@sentry/cloudflare (withSentry) - minified 181.78 kB - -
@sentry/cloudflare (withSentry) 449.94 kB - -

View base workflow run

Comment thread packages/remix/src/server/integrations/tracing-channel.ts Outdated
@mydea mydea force-pushed the francesconovy/js-2483-rewrite-remixinstrumentation-to-orchestrion branch from 41d5562 to 24c9db3 Compare July 15, 2026 07:42
Comment thread packages/remix/src/server/integrations/RemixIntegration.ts
mydea and others added 7 commits July 15, 2026 12:46
`instrumentRemix` only subscribed to `callRouteAction` when
`actionFormDataAttributes` was configured, so ACTION spans were never created
unless form-data capture was opted into. The OTel instrumentation always patched
`callRouteAction` and used those keys only for optional attribute extraction.

Always subscribe; the request clone + async form-data read now happen only when
capture is configured. Adds a regression test (separate file so the channel
subscribes with no form-data config) asserting ACTION spans are still created.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The OpenTelemetry branch of `remixIntegration` passed the form-data key map
straight into `instrumentRemixWithOpenTelemetry`, which expects
`{ actionFormDataAttributes: ... }`. As a result the map was treated as the
whole instrumentation config, so `RemixInstrumentation`'s default
`{ _action: 'actionType' }` mapping stayed in place — applying even when capture
wasn't configured, and ignoring the opted-in keys when it was.

Wrap the map in the options object. Adds a test for the OTel branch asserting the
call shape (both opted-in and not).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The build-injection guard only asserted the `requestHandler` and
`callRouteLoader` publishers, but the transform config also injects
`matchServerRoutes` and `callRouteAction`. A silent failure to inject either of
those would have slipped past the guard, whose whole purpose is to prove
build-time injection. Assert all four channels.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea mydea force-pushed the francesconovy/js-2483-rewrite-remixinstrumentation-to-orchestrion branch from 929eaf5 to e524832 Compare July 15, 2026 10:48
Comment thread packages/remix/src/server/integrations/tracing-channel.ts
mydea and others added 2 commits July 15, 2026 13:05
`deferSpanEnd` read the form data only at `asyncEnd`, after `callRouteAction` had
already returned. A channel can't delay the action promise the way the vendored
instrumentation did, so the parent `requestHandler` span could finish and flush
the transaction before the form-data attributes were applied and the ACTION span
ended, dropping that data.

Start the form-data read at span start (from a clone taken before the action
consumes the body) so it overlaps the action's execution. By `asyncEnd` the read
is virtually always resolved, so applying the attributes and ending the span
costs a single microtask - comfortably inside the response-rendering gap before
the parent span ends.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@mydea mydea changed the title feat(remix): Rewrite RemixInstrumentation to orchestrion feat(remix): Add orchestrion-based remix instrumentation Jul 15, 2026
@mydea mydea marked this pull request as ready for review July 15, 2026 11:58
@mydea mydea requested review from a team as code owners July 15, 2026 11:58
@mydea mydea requested review from chargome, nicohrubec and s1gr1d and removed request for a team July 15, 2026 11:58

@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 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 7957bd3. Configure here.

// Additional things that need to be bundled but are not covered by the above
// Remix needs to bundle this so @remix-run/server-runtime is _also_ bundled
'@remix-run/node',
];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Global Remix force-bundle leak

Low Severity

instrumentedModuleNames always appends @remix-run/node for every orchestrion consumer, not only Remix apps. That helper feeds Vite ssr.noExternal and webpack/esbuild external stripping globally, so a Remix-specific bundling requirement leaks into Nest, Express, and other SDK setups.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 7957bd3. Configure here.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this is fine, same with all others, if this is not found it will simply be ignored

Comment on lines +22 to +23
const MATCH_ROUTE_ID = 'match.route.id';
const MATCH_PARAMS = 'match.params';

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.

Those attributes should probably also be added to sentry conventions (as deprecated) as we can use http.route and our url.path.parameter.<key instead.

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.

Rewrite RemixInstrumentation to orchestrion

2 participants