Skip to content

feat(node): Rewrite knex instrumentation to orchestrion tracing channels - #22237

Merged
logaretm merged 2 commits into
developfrom
awad/js-2408-rewrite-opentelemetryinstrumentation-knex-to-orchestrion
Jul 15, 2026
Merged

feat(node): Rewrite knex instrumentation to orchestrion tracing channels#22237
logaretm merged 2 commits into
developfrom
awad/js-2408-rewrite-opentelemetryinstrumentation-knex-to-orchestrion

Conversation

@logaretm

@logaretmlogaretm commented Jul 13, 2026

Copy link
Copy Markdown
Member

Migrates the knex integration off the vendored InstrumentationBase monkey-patch onto a node:diagnostics_channel subscriber whose channels are injected by the orchestrion code transform. The vendored OTel path stays as the fallback when orchestrion isn't injected.

closes#20757

@linear-code

Copy link
Copy Markdown

JS-2408

@github-actions

github-actionsBot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.65 kB--
@sentry/browser - with treeshaking flags26.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 flags75.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/react29.45 kB--
@sentry/react (incl. Tracing)48.68 kB--
@sentry/vue33.08 kB--
@sentry/vue (incl. Tracing)48.4 kB--
@sentry/svelte27.67 kB--
CDN Bundle30.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 - uncompressed89.58 kB--
CDN Bundle (incl. Tracing) - uncompressed146.33 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed94.29 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed150.31 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed219.02 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed265.54 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed269.5 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed279.24 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed283.19 kB--
@sentry/nextjs (client)51.22 kB--
@sentry/sveltekit (client)46.86 kB--
@sentry/core/server78.51 kB--
@sentry/core/browser64.86 kB--
@sentry/node-core62.79 kB+0.01%+1 B 🔺
@sentry/node125.19 kB+0.01%+1 B 🔺
@sentry/node (incl. diagnostics channel injection)140.18 kB+0.15%+202 B 🔺
@sentry/node/import (ESM hook with diagnostics-channel injection)69.96 kB--
@sentry/node/light50.8 kB+0.01%+1 B 🔺
@sentry/node - without tracing74.17 kB+0.01%+1 B 🔺
@sentry/aws-serverless83.39 kB-0.01%-3 B 🔽
@sentry/cloudflare (withSentry) - minified181.79 kB--
@sentry/cloudflare (withSentry)449.98 kB--

View base workflow run

@logaretm
logaretmforce-pushed the awad/js-2408-rewrite-opentelemetryinstrumentation-knex-to-orchestrion branch 3 times, most recently from fea4e2e to f04f9e0CompareJuly 13, 2026 20:46
@logaretm
logaretm marked this pull request as ready for review July 13, 2026 20:53
@logaretm
logaretm requested review from a team as code ownersJuly 13, 2026 20:53
@logaretm
logaretm requested review from andreiborza, isaacs and mydea and removed request for a teamJuly 13, 2026 20:53
@logaretm
logaretmforce-pushed the awad/js-2408-rewrite-opentelemetryinstrumentation-knex-to-orchestrion branch from f04f9e0 to 189751cCompareJuly 13, 2026 21:34

@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 2 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 189751c. Configure here.

Comment threadpackages/node/src/integrations/tracing/knex/index.ts
Comment threadpackages/node/src/integrations/tracing/knex/index.ts
@logaretm
logaretmforce-pushed the awad/js-2408-rewrite-opentelemetryinstrumentation-knex-to-orchestrion branch from 189751c to 204a03aCompareJuly 14, 2026 15:23
Migrate the knex integration off the vendored `InstrumentationBase`
monkey-patch onto a `node:diagnostics_channel` subscriber whose channels
are injected by the orchestrion code transform. The OTel path stays as the
fallback when orchestrion isn't injected.
knex is opt-in (not a default performance integration), so the `@sentry/node`
factory picks the path itself in `setupOnce` via `isOrchestrionInjected()`
rather than the central `channelIntegrations` swap.
`Runner.query` produces the span; `Client.queryBuilder`/`schemaBuilder`/`raw`
are wrapped for bookkeeping so the span active at builder-creation time is
reused as the parent when the query runs later.
Fixes#20757
Add an opt-in `denoKnexIntegration` that reuses the shared knex channel
subscriber from `@sentry/server-utils` and installs Deno's AsyncLocalStorage
context strategy, mirroring the other Deno DB integrations. Exported but kept
out of the default set, matching knex being opt-in on Node.
@logaretm
logaretmforce-pushed the awad/js-2408-rewrite-opentelemetryinstrumentation-knex-to-orchestrion branch from 9caa486 to 0fe09bfCompareJuly 14, 2026 17:37

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

Looks familiar. Basically the same as dataloader.

@logaretm
logaretm merged commit 2cbacb5 into developJul 15, 2026
428 of 430 checks passed
@logaretm
logaretm deleted the awad/js-2408-rewrite-opentelemetryinstrumentation-knex-to-orchestrion branch July 15, 2026 21:57
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 @opentelemetry/instrumentation-knex to orchestrion

3 participants

@logaretm@isaacs@mydea