Skip to content

Commit

Permalink
Use sample rate with stream destroyed stats. (#1294) (#1295)
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentwschau authored Mar 30, 2024
1 parent a6bd5dc commit d59bd14
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions indexer/services/socks/src/helpers/wss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,17 @@ export function sendMessageString(
// Don't log an error as this can be expected if the client disconnects.
stats.increment(
`${config.SERVICE_NAME}.ws_send.write_epipe_errors`,
1,
config.MESSAGE_FORWARDER_STATSD_SAMPLE_RATE,
);
} else if (error?.message.includes?.('write ECONNRESET')) {
// This error means that the client abruptly disconnected without sending a proper "close"
// message (or the message is delayed). In this case, we should terminate the connection
// immediately.
stats.increment(
`${config.SERVICE_NAME}.ws_send.write_econn_reset_errors`,
1,
config.MESSAGE_FORWARDER_STATSD_SAMPLE_RATE,
);
try {
ws.close(
Expand All @@ -138,6 +142,7 @@ export function sendMessageString(
stats.increment(
`${config.SERVICE_NAME}.ws_send.stream_destroyed_errors`,
1,
config.MESSAGE_FORWARDER_STATSD_SAMPLE_RATE,
{ action: 'close' },
);
} else {
Expand All @@ -151,6 +156,7 @@ export function sendMessageString(
stats.increment(
`${config.SERVICE_NAME}.ws_send.stream_destroyed_errors`,
1,
config.MESSAGE_FORWARDER_STATSD_SAMPLE_RATE,
{ action: 'send' },
);
} else {
Expand Down

0 comments on commit d59bd14

Please sign in to comment.