Skip to content

ref(node): Streamline knex instrumentation#21561

Draft
logaretm wants to merge 1 commit into
developfrom
awad/js-2385-streamline-opentelemetryinstrumentation-knex
Draft

ref(node): Streamline knex instrumentation#21561
logaretm wants to merge 1 commit into
developfrom
awad/js-2385-streamline-opentelemetryinstrumentation-knex

Conversation

@logaretm

@logaretm logaretm commented Jun 15, 2026

Copy link
Copy Markdown
Member

Streamlines the vendored knex instrumentation by moving it off the OpenTelemetry tracing APIs onto Sentry's span APIs.

In this integration it was possible to use startSpan directly as all APIs seem to be promise based and there is no risk of lazy thenables as far as I can tell.

@linear-code

linear-code Bot commented Jun 15, 2026

Copy link
Copy Markdown

JS-2385

Refactors the vendored knex instrumentation off the OpenTelemetry tracing
APIs onto Sentry's span APIs, mirroring the mongoose (#21481) and mysql2
(#21509) streamlines.

- Replace `tracer.startSpan` + manual `context.with`/`.then`/`.catch` with
  `startSpan`. `Runner.query` returns a real, already-executing Promise, so
  `startSpan` can safely await it and auto-end the span while keeping it active
  so the underlying `pg`/`mysql2` driver spans nest correctly.
- Preserve the build-time `contextSymbol` parent + require-parent-span behavior
  (only instrument queries that run within an existing trace).
- Bake the `auto.db.otel.knex` origin into the span attributes and drop the
  `spanStart` hook from `index.ts`.
- Drop the env-gated `OTEL_SEMCONV_STABILITY_OPT_IN` dual-emission; only the OLD
  semantic conventions (`db.system`, `db.statement`, ...) were ever emitted.
  Behavior change: the unsupported stable-semconv opt-in is no longer honored.
- Hardcode `requireParentSpan`/`maxQueryLength` (the integration only ever used
  the defaults), delete the now-dead `types.ts`/`constants.ts` and
  `otelExceptionFromKnexError`, drop OTel `recordException`, and remove the
  blanket `eslint-disable`.
- Extend the `pg` integration suite with a failing query to cover the error
  path (`status: internal_error`).
@logaretm logaretm force-pushed the awad/js-2385-streamline-opentelemetryinstrumentation-knex branch from 125fe11 to a32abea Compare June 15, 2026 20:55
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.

1 participant