-
Notifications
You must be signed in to change notification settings - Fork 341
Description
Tracer Version(s)
^5.24.0
Node.js Version(s)
20
Bug Report
Description:
When running ioredis in cluster mode, the dd-trace-js instrumentation hook does not propagate to the cluster client instance. This causes tracing to not work correctly with Redis in cluster mode. The issue was observed in our service where the Redis client is initialized in cluster mode:
if (redisConfig.mode?.toLowerCase() === 'cluster') {
const options: ClusterOptions = {
redisOptions: {
connectTimeout,
username,
password,
showFriendlyErrorStack: true
},
enableOfflineQueue: true,
dnsLookup: (address, callback) => callback(null, address) // https://github.com/luin/ioredis#special-note-aws-elasticache-clusters-with-tls
}
if (redisConfig.url.startsWith('rediss://')) {
options.redisOptions!.tls = tlsNoHostnameValidation
}
return new Cluster([redisConfig.url], options)
}
The dd-trace-js hook code for ioredis (instrumentation source here) appears to patch only the base Redis client but not the cluster client.
Steps to Reproduce:
Configure ioredis client in cluster mode (new Redis.Cluster(...)).
Use dd-trace-js for instrumentation.
Observe that Redis commands traced by the cluster client are not captured or linked in traces, unlike single-node mode.
Expected Behavior:
The tracing hooks should propagate and instrument ioredis cluster clients fully, allowing spans to be created for commands executed on the Redis cluster.
Actual Behavior:
No traces are created for cluster client commands because the instrumentation is missing or ineffective.
Environment:
dd-trace-js version: (please fill)
Node.js version: (please fill)
ioredis version: (please fill)
Redis cluster mode enabled (REDIS_MODE=cluster)
Additional Context:
Since the service is explicitly set to use Redis in cluster mode, this lack of instrumentation means the tracing data is incomplete for Redis commands. We either need a feature request to support ioredis cluster mode in dd-trace-js, or guidance to manually instrument cluster clients.
Reproduction Code
No response
Error Logs
No response
Tracer Config
No response
Operating System
No response
Bundling
Unsure