Skip to content

ref(node): Streamline mongodb instrumentation#21619

Open
logaretm wants to merge 1 commit into
developfrom
awad/js-2388-streamline-opentelemetryinstrumentation-mongodb
Open

ref(node): Streamline mongodb instrumentation#21619
logaretm wants to merge 1 commit into
developfrom
awad/js-2388-streamline-opentelemetryinstrumentation-mongodb

Conversation

@logaretm

@logaretm logaretm commented Jun 17, 2026

Copy link
Copy Markdown
Member

Streamlines the vendored mongodb instrumentation to use Sentry's span APIs instead of the OpenTelemetry tracing APIs.

@linear-code

linear-code Bot commented Jun 17, 2026

Copy link
Copy Markdown

JS-2388

@github-actions

github-actions Bot commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 27.45 kB - -
@sentry/browser - with treeshaking flags 25.88 kB - -
@sentry/browser (incl. Tracing) 45.88 kB - -
@sentry/browser (incl. Tracing + Span Streaming) 48.11 kB - -
@sentry/browser (incl. Tracing, Profiling) 50.65 kB - -
@sentry/browser (incl. Tracing, Replay) 85.08 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 74.68 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 89.78 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 102.44 kB - -
@sentry/browser (incl. Feedback) 44.62 kB - -
@sentry/browser (incl. sendFeedback) 32.25 kB - -
@sentry/browser (incl. FeedbackAsync) 37.38 kB - -
@sentry/browser (incl. Metrics) 28.52 kB - -
@sentry/browser (incl. Logs) 28.76 kB - -
@sentry/browser (incl. Metrics & Logs) 29.45 kB - -
@sentry/react 29.25 kB - -
@sentry/react (incl. Tracing) 48.17 kB - -
@sentry/vue 32.56 kB - -
@sentry/vue (incl. Tracing) 47.74 kB - -
@sentry/svelte 27.48 kB - -
CDN Bundle 29.86 kB - -
CDN Bundle (incl. Tracing) 48.28 kB - -
CDN Bundle (incl. Logs, Metrics) 31.4 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) 49.58 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) 70.71 kB - -
CDN Bundle (incl. Tracing, Replay) 85.61 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) 86.88 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 91.46 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) 92.71 kB - -
CDN Bundle - uncompressed 88.8 kB - -
CDN Bundle (incl. Tracing) - uncompressed 146.04 kB - -
CDN Bundle (incl. Logs, Metrics) - uncompressed 93.5 kB - -
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed 150.02 kB - -
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed 218.33 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 264.91 kB - -
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed 268.87 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 278.61 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed 282.56 kB - -
@sentry/nextjs (client) 50.58 kB - -
@sentry/sveltekit (client) 46.27 kB - -
@sentry/core/server 76.16 kB - -
@sentry/core/browser 63.31 kB - -
@sentry/node-core 61.84 kB - -
@sentry/node 126.81 kB -0.72% -919 B 🔽
@sentry/node - without tracing 74.22 kB - -
@sentry/aws-serverless 85.47 kB - -
@sentry/cloudflare (withSentry) - minified 174.48 kB - -
@sentry/cloudflare (withSentry) 436.52 kB - -

View base workflow run

@logaretm logaretm force-pushed the awad/js-2388-streamline-opentelemetryinstrumentation-mongodb branch from 8c0b859 to d79e1cd Compare June 17, 2026 18:29
@logaretm logaretm marked this pull request as ready for review June 17, 2026 18:45
@logaretm logaretm requested a review from a team as a code owner June 17, 2026 18:45
@logaretm logaretm requested review from JPeer264, andreiborza, mydea and nicohrubec and removed request for a team June 17, 2026 18:45
Comment thread packages/node/src/integrations/tracing/mongo/vendored/utils.ts
Streamlines the vendored `mongodb` instrumentation to use Sentry's span
APIs instead of the OpenTelemetry tracing APIs, following the
redis/pg/mongoose precedent.

- Replace `tracer.startSpan` with `startInactiveSpan`, the
  `trace.getSpan(context.active())` + `requireParentSpan` guard with a
  `getActiveSpan()` check, `SpanStatusCode.ERROR` with `SPAN_STATUS_ERROR`,
  and the `context.with(...)`/`context.bind(...)` propagation with
  `withActiveSpan` (result-handler re-activation and the pool `checkOut`
  rebind). Drop `recordException` and the `_diag` logger.
- Drop the OTel connection-usage metrics: the SDK wires up no
  `MeterProvider`, so `this.meter` is the no-op meter and every `add` was
  dead. Also removes the session and connect patches that existed only to
  feed those metrics (they create no spans, so span output is unchanged).
- Drop the `SemconvStability` dual-emission and keep the OLD semconv
  attributes only (the STABLE path was env-gated behind
  `OTEL_SEMCONV_STABILITY_OPT_IN` and never enabled by the SDK).
- Remove config the SDK never passes (`responseHook`, the configurable
  `dbStatementSerializer`, `requireParentSpan`); move the always-on
  statement serializer into the vendored code and bake the
  `auto.db.otel.mongo` origin into the span attributes instead of an
  `index.ts` responseHook.
- Drop the blanket eslint-disable, type the module, and split the helpers
  (`utils.ts`) and wrap factories (`patches.ts`) out of the class to keep
  each vendored file within `max-lines`.

Removes the config-passing `Mongo` unit test (its serializer logic is
covered end-to-end by the integration suite) and extends the real suite
with an error path: a server-rejected query asserts `status:
'internal_error'` with the origin and `db.statement` preserved.
@logaretm logaretm force-pushed the awad/js-2388-streamline-opentelemetryinstrumentation-mongodb branch from d79e1cd to d0846c8 Compare June 18, 2026 02:36

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

if (span) {
if (error instanceof Error) {
span.setStatus({ code: SPAN_STATUS_ERROR, message: error.message });
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Error span status uses raw message

Medium Severity

On failed commands, patchEnd sets span status with message: error.message. Exported span status uses that message verbatim via getStatusMessage, so it may not be the canonical internal_error value the new integration test asserts for failed finds.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit d0846c8. Configure here.

v4PatchConnectionPool,
v4UnpatchConnectionPool,
),
new InstrumentationNodeModuleFile(

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.

q: Is there a specific reason why this is not needed anymore?

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.

2 participants