Skip to content

fix(otel): record client connection errors - #3259

Merged
nkaradzhov merged 1 commit into
redis:masterfrom
PavelPashov:fix/otel-client-connection-error-metrics
Apr 30, 2026
Merged

nkaradzhov merged 1 commit into
redis:masterfrom
PavelPashov:fix/otel-client-connection-error-metrics

Conversation

@PavelPashov

@PavelPashov PavelPashov commented Apr 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

Describe your pull request here


Checklist

  • Does npm test pass with this change (including linting)?
  • Is the new or changed code fully tested?
  • Is a documentation update included (if this change modifies existing APIs, or introduces new ones)?

Note

Medium Risk
Touches core socket error/reconnect paths and increases diagnostics-channel error publishing, which could affect error reporting volume and downstream telemetry behavior, but changes are additive and covered by a new metric test.

Overview
Client connection failures are now observable via OTel error metrics. The socket layer (client/socket.ts) now publishes CHANNELS.ERROR events (with clientId, origin, internal) when reconnect strategy evaluation fails, when reconnect is aborted/returns an error, during connect retry loops, and on socket 'error' events.

Tests in opentelemetry/metrics.spec.ts are updated to use a single diagnostics_channel import and add a new unit test asserting that a failed client.connect() (with reconnectStrategy: false) increments redisClientErrors with the expected network category and internal=false attributes.

Reviewed by Cursor Bugbot for commit 3cf8152. Bugbot is set up for automated code reviews on this repo. Configure here.

@PavelPashov
PavelPashov requested a review from nkaradzhov April 27, 2026 08:10

@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

Reviewed by Cursor Bugbot for commit 83c5fd4. Configure here.

origin: 'client',
internal: false,
clientId: this.#clientId
}));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Double error metric publish in socket error path

Medium Severity

When #onSocketError is called on a ready, open socket whose reconnect strategy returns false or Error, the same error gets published to CHANNELS.ERROR twice — once unconditionally in #onSocketError and again inside #shouldReconnect. Since the OTel metrics subscriber increments redisClientErrors on every publish with no deduplication, this double-counts the error in metrics. The new test doesn't catch this because it tests a failed initial connection (socket was never ready), so only the #shouldReconnect path fires.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 83c5fd4. Configure here.

@PavelPashov PavelPashov Apr 27, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@nkaradzhov I've created a TODO for this, however this seems to be incorrect behavior in general and not just related to OTel metrics, wonder if it's worth creating an issue, as I'd rather not fix it in this PR.

@PavelPashov
PavelPashov force-pushed the fix/otel-client-connection-error-metrics branch from 83c5fd4 to 3cf8152 Compare April 27, 2026 08:25
@nkaradzhov
nkaradzhov merged commit 452ce0d into redis:master Apr 30, 2026
17 checks passed
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