ref(node): Streamline redis instrumentation#21582
Conversation
| "typescript/no-unsafe-member-access": "off", | ||
| "typescript/no-this-alias": "off", | ||
| "max-lines": "off", | ||
| "no-bitwise": "off" |
There was a problem hiding this comment.
Not needed after streamline
size-limit report 📦
|
| } | ||
| attributes[SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN] = 'auto.db.otel.redis'; | ||
| const span = instrumentation.tracer.startSpan(`${RedisInstrumentationV2_V3.COMPONENT}-${cmd.command}`, { | ||
| const span = startInactiveSpan({ |
There was a problem hiding this comment.
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 😅
There was a problem hiding this comment.
I will not miss monkey patching man
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.
3941fd0 to
bedcd11
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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(); |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit bedcd11. Configure here.


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.12and older v5 releases so that we can test all paths in actual tests.