Repository navigation
fix(otel): record client connection errors - #3259
nkaradzhov merged 1 commit into
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Reviewed by Cursor Bugbot for commit 83c5fd4. Configure here.
| origin: 'client', | ||
| internal: false, | ||
| clientId: this.#clientId | ||
| })); |
There was a problem hiding this comment.
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)
Reviewed by Cursor Bugbot for commit 83c5fd4. Configure here.
There was a problem hiding this comment.
@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.
83c5fd4 to
3cf8152
Compare


Description
Checklist
npm testpass with this change (including linting)?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 publishesCHANNELS.ERRORevents (withclientId,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.tsare updated to use a singlediagnostics_channelimport and add a new unit test asserting that a failedclient.connect()(withreconnectStrategy: false) incrementsredisClientErrorswith the expected network category andinternal=falseattributes.Reviewed by Cursor Bugbot for commit 3cf8152. Bugbot is set up for automated code reviews on this repo. Configure here.