Skip to content

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

Merged
mydea merged 9 commits into
developfrom
francesconovy/js-2483-rewrite-remixinstrumentation-to-orchestrion
Jul 20, 2026
Merged

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

Conversation

@mydea

@mydeamydea 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

Copy link
Copy Markdown

JS-2483

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

github-actionsBot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.74 kB--
@sentry/browser - with treeshaking flags26.18 kB--
@sentry/browser (incl. Tracing)46.55 kB--
@sentry/browser (incl. Tracing + Span Streaming)48.35 kB--
@sentry/browser (incl. Tracing, Profiling)51.36 kB--
@sentry/browser (incl. Tracing, Replay)85.81 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags75.46 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)90.52 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)103.2 kB--
@sentry/browser (incl. Feedback)44.93 kB--
@sentry/browser (incl. sendFeedback)32.54 kB--
@sentry/browser (incl. FeedbackAsync)37.68 kB--
@sentry/browser (incl. Metrics)28.83 kB--
@sentry/browser (incl. Logs)29.06 kB--
@sentry/browser (incl. Metrics & Logs)29.75 kB--
@sentry/react29.54 kB--
@sentry/react (incl. Tracing)48.81 kB--
@sentry/vue33.17 kB--
@sentry/vue (incl. Tracing)48.52 kB--
@sentry/svelte27.77 kB--
CDN Bundle30.14 kB--
CDN Bundle (incl. Tracing)48.52 kB--
CDN Bundle (incl. Logs, Metrics)31.73 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.82 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.97 kB--
CDN Bundle (incl. Tracing, Replay)86.03 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)87.34 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.83 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)93.09 kB--
CDN Bundle - uncompressed89.87 kB--
CDN Bundle (incl. Tracing) - uncompressed146.68 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed94.58 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed150.66 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed219.32 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed265.89 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed269.86 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed279.6 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed283.55 kB--
@sentry/nextjs (client)51.36 kB--
@sentry/sveltekit (client)46.98 kB--
@sentry/core/server78.69 kB--
@sentry/core/browser65.06 kB--
@sentry/node-core63.21 kB+0.01%+2 B 🔺
@sentry/node125.52 kB--
@sentry/node (incl. diagnostics channel injection)148.23 kB+0.12%+172 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection)70.03 kB--
@sentry/node/light51.32 kB-0.01%-1 B 🔽
@sentry/node - without tracing74.71 kB--
@sentry/aws-serverless83.92 kB--
@sentry/cloudflare (withSentry) - minified182.12 kB--
@sentry/cloudflare (withSentry)451.05 kB--

View base workflow run

Comment threadpackages/remix/src/server/integrations/tracing-channel.ts Outdated
@mydea
mydeaforce-pushed the francesconovy/js-2483-rewrite-remixinstrumentation-to-orchestrion branch from 41d5562 to 24c9db3CompareJuly 15, 2026 07:42
Comment threadpackages/remix/src/server/integrations/RemixIntegration.ts
@mydea
mydeaforce-pushed the francesconovy/js-2483-rewrite-remixinstrumentation-to-orchestrion branch from 929eaf5 to e524832CompareJuly 15, 2026 10:48
Comment threadpackages/remix/src/server/integrations/tracing-channel.ts
@mydeamydea changed the title feat(remix): Rewrite RemixInstrumentation to orchestrionfeat(remix): Add orchestrion-based remix instrumentationJul 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 ownersJuly 15, 2026 11:58
@mydea
mydea requested review from chargome, nicohrubec and s1gr1d and removed request for a teamJuly 15, 2026 11:58

@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 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 CursorFix in Web

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

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.

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.

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.

yes, totally. I wanted to leave this to a follow up task - imho once we are done it makes sense to go look for any attribute we set that is not imported from semantic attribtues and bulk-add them!

Comment threadpackages/server-utils/src/orchestrion/config/index.ts
mydeaand others added 9 commits July 17, 2026 10:00
`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>
`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
mydeaforce-pushed the francesconovy/js-2483-rewrite-remixinstrumentation-to-orchestrion branch from 7957bd3 to cfbb502CompareJuly 17, 2026 08:00

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

Looks good, just one comment!

Comment on lines +93 to +95
// 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
Member

Choose a reason for hiding this comment

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

l: I know this will be ignored if unused, but I'd vote for moving this into the vite plugin for remix once we have either a orchestrion opt-in flag or latest when we enable orchestrion by default

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.

yes that makes sense I guess! 👍

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

Not a Remix pro, but implementation LGTM

@mydea
mydea merged commit e47e5d8 into developJul 20, 2026
313 checks passed
@mydea
mydea deleted the francesconovy/js-2483-rewrite-remixinstrumentation-to-orchestrion branch July 20, 2026 07:27
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.

Rewrite RemixInstrumentation to orchestrion

4 participants

@mydea@JPeer264@chargome@s1gr1d