Skip to content

feat(server-utils): Rewrite @opentelemetry/instrumentation-dataloader to orchestrion#22236

Merged
logaretm merged 5 commits into
developfrom
feat/dataloader-orchestrion
Jul 14, 2026
Merged

feat(server-utils): Rewrite @opentelemetry/instrumentation-dataloader to orchestrion#22236
logaretm merged 5 commits into
developfrom
feat/dataloader-orchestrion

Conversation

@logaretm

@logaretm logaretm commented Jul 13, 2026

Copy link
Copy Markdown
Member

Rewrites the dataloader integration to a diagnostics-channel listener instead of InstrumentationBase, with orchestrion injecting the channels into dataloader's constructor and prototype methods. Follows the mysql/amqplib pattern, and produces the same spans (load/loadMany/prime/clear/clearAll plus the linked batch span).

There was a complication because dataloader is not a default integration, so it requires a different way to wire it in. I followed the same approach as in Nest PR.

The existing node integration test now runs against the real orchestrion path under INJECT_ORCHESTRION, with the span origin parameterized like amqplib.

closes #20749

@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.65 kB - -
@sentry/browser - with treeshaking flags 26.1 kB - -
@sentry/browser (incl. Tracing) 46.42 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.21 kB - -
@sentry/browser (incl. Tracing, Profiling) 51.2 kB - -
@sentry/browser (incl. Tracing, Replay) 85.67 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 75.31 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.58 kB - -
@sentry/browser (incl. Metrics) 28.74 kB - -
@sentry/browser (incl. Logs) 28.98 kB - -
@sentry/browser (incl. Metrics & Logs) 29.67 kB - -
@sentry/react 29.45 kB - -
@sentry/react (incl. Tracing) 48.68 kB - -
@sentry/vue 33.08 kB - -
@sentry/vue (incl. Tracing) 48.4 kB - -
@sentry/svelte 27.67 kB - -
CDN Bundle 30.05 kB - -
CDN Bundle (incl. Tracing) 48.41 kB - -
CDN Bundle (incl. Logs, Metrics) 31.64 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.71 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.87 kB - -
CDN Bundle (incl. Tracing, Replay) 85.9 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 87.21 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.7 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.97 kB - -
CDN Bundle - uncompressed 89.58 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.33 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 94.29 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.31 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 219.02 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 265.54 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 269.5 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 279.24 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 283.19 kB - -
@sentry/nextjs (client) 51.22 kB - -
@sentry/sveltekit (client) 46.86 kB - -
@sentry/core/server 78.51 kB - -
@sentry/core/browser 64.86 kB - -
@sentry/node-core 62.79 kB - -
@sentry/node 125.19 kB +0.01% +1 B 🔺
@sentry/node (incl. diagnostics channel injection) 139.97 kB +0.08% +108 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection) 69.96 kB - -
@sentry/node/light 50.8 kB +0.01% +1 B 🔺
@sentry/node - without tracing 74.17 kB -0.01% -1 B 🔽
@sentry/aws-serverless 83.39 kB - -
@sentry/cloudflare (withSentry) - minified 181.79 kB - -
@sentry/cloudflare (withSentry) 449.98 kB - -

View base workflow run

@logaretm logaretm force-pushed the feat/dataloader-orchestrion branch from ace18fe to 70ef225 Compare July 13, 2026 19:16
@logaretm logaretm marked this pull request as ready for review July 13, 2026 19:32
@logaretm logaretm requested review from a team as code owners July 13, 2026 19:32
@logaretm logaretm requested review from JPeer264, isaacs and mydea and removed request for a team July 13, 2026 19:32
Comment thread packages/server-utils/src/orchestrion/config/dataloader.ts Outdated
@logaretm logaretm force-pushed the feat/dataloader-orchestrion branch 2 times, most recently from 7ae5c62 to 1578d2e Compare July 13, 2026 20:00
@logaretm logaretm force-pushed the feat/dataloader-orchestrion branch from 1578d2e to 75da927 Compare July 13, 2026 20:05

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

Some comments. Couldn't really find much to take issue with. It'd be good to add a Deno integration (since broad platform coverage is also the goal here, and it's usually easy to do; if it's not easy, then probably skip it, do it later, etc.)

Also, it'd be nice if there was a test to ensure we get the right nesting and durations, since that was the mistake the clankers found, but tbh, I think it's very unlikely we're going to randomly change a kind: 'Async' to kind: 'Sync' without a very good reason.

Comment thread packages/server-utils/src/integrations/tracing-channel/dataloader.ts Outdated
// reliable by `setupOnce`. When the diagnostics channels are injected (runtime hook or bundler
// plugin), subscribe to them; otherwise fall back to the vendored OTel instrumentation.
if (isOrchestrionInjected()) {
dataloaderChannelIntegration().setupOnce?.();

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.

low/consistency nit: It seems like this defines a whole integration, only to call setupOnce on it. Could it just export a subscribeToDataLoaderChannels rather than a full defineIntegration, like how nest does subscribeToNestChannels? (What's here works and is fine, but it's a deviation from the other pattern, and we probably will benefit by either picking one, or deciding when to use one or the other.)

@logaretm logaretm Jul 14, 2026

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 a bit awkward, I think exposing subscribe functions can get muddy like we had with redis.

The .setupOnce?.() reach-in in the node factory is a side effect of the OTel-vs-channel swap. Once we drop the vendored OTel path, there would be no swap and this becomes a normal opt-in integration you add to integrations directly.

Nest is kinda self contained over there, so maybe it's a bit different?

I'd lean toward leaving it, but happy to change it to match if you feel strongly. WDYT?

@logaretm logaretm force-pushed the feat/dataloader-orchestrion branch from 75da927 to 5ee4391 Compare July 14, 2026 02:44

@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 5ee4391. Configure here.

Comment thread packages/server-utils/src/integrations/tracing-channel/dataloader.ts Outdated
logaretm added 5 commits July 14, 2026 11:22
…r` to orchestrion

Replaces the `InstrumentationBase`-based OTel dataloader instrumentation with a
diagnostics-channel listener, with orchestrion injecting the channels into
`dataloader`'s constructor and prototype methods.

`dataloaderIntegration` is opt-in (never a default), so the default-swap in
`_init` doesn't apply (a user's explicit instance wins integration dedup).
Like `@sentry/nestjs`'s `Nest`, the `@sentry/node` factory picks the
channel-vs-OTel path itself at `setupOnce` via `isOrchestrionInjected()`.
@logaretm logaretm force-pushed the feat/dataloader-orchestrion branch from 32e4179 to bbae2cf Compare July 14, 2026 15:23
@logaretm logaretm merged commit c85347c into develop Jul 14, 2026
222 checks passed
@logaretm logaretm deleted the feat/dataloader-orchestrion branch July 14, 2026 15:48
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 @opentelemetry/instrumentation-dataloader to orchestrion

2 participants