add OpenTelemetry metrics instrumentation#3110
add OpenTelemetry metrics instrumentation#3110PavelPashov wants to merge 52 commits intoredis:masterfrom
Conversation
a11117e to
5fb1791
Compare
1be4565 to
03db1a2
Compare
There was a problem hiding this comment.
❌ The following Jit checks failed to run:
- license-compliance-checker
- secret-detection-trufflehog
- software-component-analysis-js
- static-code-analysis-semgrep-pro
#jit_bypass_commit in this PR to bypass, Jit Admin privileges required.
More info in the Jit platform.
1106f8a to
242e98d
Compare
|
This is an exciting feature, I hope it makes it to main! |
❌ Security scan failedSecurity scan failed: Branch feat/add-opentelemetry-metrics does not exist in the remote repository 💡 Need to bypass this check? Comment |
364ff86 to
30b0e8c
Compare
❌ Security scan failedSecurity scan failed: Branch feat/add-opentelemetry-metrics does not exist in the remote repository 💡 Need to bypass this check? Comment |
1 similar comment
❌ Security scan failedSecurity scan failed: Branch feat/add-opentelemetry-metrics does not exist in the remote repository 💡 Need to bypass this check? Comment |
0e91b34 to
e2cc888
Compare
af9f0fb to
d0f42d3
Compare
packages/client/lib/RESP/types.ts
Outdated
| TRANSFORM_LEGACY_REPLY?: boolean; | ||
| transformReply: TransformReply | Record<RespVersions, TransformReply>; | ||
| unstableResp3?: boolean; | ||
| onSuccess?: (args: ReadonlyArray<RedisArgument>, reply: unknown, clientId: string) => void; |
There was a problem hiding this comment.
@nkaradzhov we might want to rename onSuccess to something more metrics/otel related
packages/client/lib/client/index.ts
Outdated
| if (command.onSuccess) { | ||
| command.onSuccess(parser.redisArgs, finalReply, this._self._clientId); |
There was a problem hiding this comment.
@nkaradzhov there might be a better way to record specific command related metrics that require the server response
| // Build the appropriate function based on options | ||
| if (options.hasIncludeCommands || options.hasExcludeCommands) { | ||
| // Version with filtering | ||
| this.createRecordOperationDuration = this.#createWithFiltering.bind(this); | ||
| } else { | ||
| this.createRecordOperationDuration = | ||
| this.#createWithoutFiltering.bind(this); | ||
| } | ||
| } |
There was a problem hiding this comment.
@nkaradzhov to make sure we don't do unnecessary checks after initiating the metrics singleton if the user hasn't provided any included or excluded commands
… in command and CSC metrics
bf97457 to
adbe066
Compare
adbe066 to
bc14732
Compare
|
Created a separated PR for conversion of ObservableGauges to up UpDownCounters. After the current PR is released I'll need to create 3 issues for:
|
No subscriber existed for this event. The original redis#3110 code only recorded at wait end, not start. Remove the speculative event. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

Description
TODO
Checklist
npm testpass with this change (including linting)?Note
Medium Risk
Touches core request/connection paths (
RedisClient,RedisSocket, queues, cluster redirection) to emit metrics and maintain per-client identity/registry, so mistakes could add overhead or skew counts. Functional behavior should be unchanged, but instrumentation around errors/closures and cache invalidation needs careful review.Overview
Adds first-class OpenTelemetry metrics support via a new
OpenTelemetry.init()entrypoint and an internal metrics/registry layer that can be enabled before client creation.Instruments core client operations to emit metrics for command durations (including
MULTI/PIPELINEbatches), connection lifecycle (create time, active count, close reasons, relaxed timeouts, handoff), resiliency/errors (including cluster redirections and maintenance notifications), pub/sub message in/out, stream lag fromXREAD/XREADGROUP, and client-side caching hits/misses/evictions.Introduces stable per-client identity (
_clientId) and aClientRegistryso observable gauges and metric attribution can track standalone clients, pools, and cluster nodes; updates pool/cluster/node creation to set roles/parent IDs and unregisters clients onclose/destroy/quit. Documentation and anotel-metrics.jsexample are added, along with new OpenTelemetry dev dependencies and extensive tests for the metrics implementation.Written by Cursor Bugbot for commit 6b04331. This will update automatically on new commits. Configure here.