Skip to content

ref(node): Streamline redis instrumentation#21582

Merged
logaretm merged 3 commits into
developfrom
awad/js-2393-streamline-opentelemetryinstrumentation-redis
Jun 17, 2026
Merged

ref(node): Streamline redis instrumentation#21582
logaretm merged 3 commits into
developfrom
awad/js-2393-streamline-opentelemetryinstrumentation-redis

Conversation

@logaretm

@logaretm logaretm commented Jun 16, 2026

Copy link
Copy Markdown
Member

Streamlines the vendored redis (node-redis) instrumentation to use Sentry's span APIs instead of the OpenTelemetry tracing APIs.

I also made sure to split up the v5 tests between pre-tracing channels releases >=5.12 and older v5 releases so that we can test all paths in actual tests.

@linear-code

linear-code Bot commented Jun 16, 2026

Copy link
Copy Markdown

JS-2393

Comment thread .oxlintrc.base.json
"typescript/no-unsafe-member-access": "off",
"typescript/no-this-alias": "off",
"max-lines": "off",
"no-bitwise": "off"

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.

Not needed after streamline

@github-actions

github-actions Bot commented Jun 16, 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.14 kB - -
@sentry/core/browser 63.29 kB - -
@sentry/node-core 61.84 kB - -
@sentry/node 127.72 kB -0.45% -566 B 🔽
@sentry/node - without tracing 74.22 kB - -
@sentry/aws-serverless 85.47 kB -0.01% -1 B 🔽
@sentry/cloudflare (withSentry) - minified 174.48 kB - -
@sentry/cloudflare (withSentry) 436.52 kB - -

View base workflow run

@logaretm logaretm marked this pull request as ready for review June 16, 2026 19:32
@logaretm logaretm requested a review from a team as a code owner June 16, 2026 19:32
@logaretm logaretm requested review from JPeer264, andreiborza, mydea and nicohrubec and removed request for a team June 16, 2026 19:32
Comment thread .oxlintrc.base.json Outdated
}
attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.db.otel.redis';
const span = instrumentation.tracer.startSpan(`${RedisInstrumentationV2_V3.COMPONENT}-${cmd.command}`, {
const span = startInactiveSpan({

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.

note: I was breaking my head if this can be simplified even more, but I think this is quite complex with the .callback being overwritten conditionally 😅

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.

I will not miss monkey patching man

logaretm added 3 commits June 17, 2026 13:20
Streamlines the vendored `redis` (node-redis) instrumentation to use
Sentry's span APIs instead of the OpenTelemetry tracing APIs, following
the ioredis precedent (#21560).

- Replace `tracer.startSpan`/`context.with(trace.setSpan(...))` with
  `startInactiveSpan`/`withActiveSpan`, `SpanStatusCode.ERROR` with
  `SPAN_STATUS_ERROR`, and drop `recordException` (a no-op in Sentry's
  pipeline) across all three classes.
- 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 dead config the SDK never passes (`dbStatementSerializer`,
  `requireParentSpan`, `semconvStability`) and the now-dead `isPipeline`
  plumbing; bake the origin into the attributes.
- Drop the blanket eslint-disable and rely on the consolidated path entry.

Also splits the node-redis test version aliases so every code path is
covered: `redis-5` now pins 5.11.0 (vendored monkey-patch, >=5.0.0 <5.12.0)
and the new `redis-5-tracing` pins >=5.12.0 (diagnostics_channel). Adds a
node-redis error-path assertion and a redis-5 cache suite.
…ation

The vendored `redis-instrumentation.test.ts` was a fake, OTel-tracer-coupled
unit test (asserted spans via an in-memory OTel exporter and the removed
`requireParentSpan` config). After the streamline it no longer compiles and
its span-capture assertions don't apply, so it's removed — matching the
ioredis precedent.

To keep coverage of the multi/pipeline deferred-span path it was the only
thing exercising, add a MULTI/EXEC call to the redis-4 and redis-5 scenarios
and assert one span per queued command in the real integration suite.
Drop the OTel context API from the v2-v3 path: translate the command
callback binding to withActiveSpan(getActiveSpan()) and remove the
createClient/create_stream patches that existed only to context.bind the
client/stream event emitters (span creation already happens at command
call time, and callback context is preserved by the command wrapper).
Replace the OTel DiagLogger (_diag) with Sentry's debug logger, and
switch the leaked OTel Span type in index.ts and types.ts to @sentry/core.
SpanKind and the setTracerProvider base-class override are kept as part of
the instrumentation/patching base.
@logaretm logaretm force-pushed the awad/js-2393-streamline-opentelemetryinstrumentation-redis branch from 3941fd0 to bedcd11 Compare June 17, 2026 17:24

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

if (err) {
span.setStatus({ code: SPAN_STATUS_ERROR, message: err.message });
}
span.end();

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Wrong failed Redis span status

Medium Severity

The new shared endSpan helper sets failed Redis command spans to SPAN_STATUS_ERROR with message: err.message (the Redis error text). New redis-cache integration tests assert status: 'internal_error', and serialized span status comes from that message via getStatusMessage, so the tests and UI status string will not match the expected canonical error status.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit bedcd11. Configure here.

@logaretm logaretm merged commit fc39574 into develop Jun 17, 2026
524 of 534 checks passed
@logaretm logaretm deleted the awad/js-2393-streamline-opentelemetryinstrumentation-redis branch June 17, 2026 18:46
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