Repository navigation
feat(client): add process-level and per-client custom attributes to OTel metrics - #3573
PavelPashov wants to merge 2 commits into
Conversation
f992653 to
0343a43
Compare
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4c4bdc61c
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit f4c4bdc. Configure here.
62c09e4 to
e25b553
Compare
Let callers set metrics.customAttributes in OpenTelemetry.init. Every metric data point from every client in the process carries them, and a custom key replaces a built-in attribute with the same key. withCustomAttributes merges them at each recording site. With no custom attributes set, the call site's object passes through as is. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Let callers set metrics.customAttributes in the client options. Every metric that client emits carries them, over the process-level ones, and two clients in one process never share or mix them. Pools pass them through their client options, clusters through defaults, and sentinels through nodeClientOptions and sentinelClientOptions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
e25b553 to
c16e7b0
Compare

Description
This pull request adds custom attributes to node-redis OpenTelemetry metrics, so users can label metrics with their own values, such as the service, team or environment. Users who run several clients in one process can also tell those clients apart in dashboards. Before this, the only per-client attribute was a random pool name, and command metrics didn't carry it.
Attributes can be set at two levels:
customAttributesinOpenTelemetry.init({ metrics }). Applies to every metric from every client in the process.metrics: { customAttributes }in the client options. Applies to every metric that client emits. Pools pass it through their client options, clusters throughdefaults, and sentinels throughnodeClientOptionsandsentinelClientOptions, the same way other per-client options work.When a key is set more than once, the most specific value wins: client attributes, then process attributes, then the attributes node-redis sets. Two clients in one process never share or mix attributes.
Checklist
npm testpass with this change (including linting)?Note
Medium Risk
Changes affect all metric data point labels; misconfigured high-cardinality custom attributes or overriding built-in keys like
server.addresscan inflate time series cost and alter grouping, though behavior is additive and well-tested.Overview
Adds custom attributes on OpenTelemetry metrics so dashboards can label series by environment, service, team, or individual Redis clients in the same process.
Configuration is two-tier:
customAttributesinOpenTelemetry.init({ metrics })applies process-wide, andmetrics.customAttributeson client options (including clusterdefaults/ sentinel node options) applies per client and wins on key conflicts over process-level values. Built-in node-redis attributes are merged first and can be replaced if the same key is used incustomAttributes.Implementation threads client options through the metrics registry handle and merges labels via
withCustomAttributeson every instrument path (commands, connections, errors, pub/sub, streams, CSC, gauges). Docs, the otel-metrics example, and unit/E2E tests cover precedence, built-in overrides, and isolation between multiple clients/clusters.Reviewed by Cursor Bugbot for commit c16e7b0. Bugbot is set up for automated code reviews on this repo. Configure here.