Skip to content
Permalink
Browse files

Add statsd metric to indicate WS backoff

[changelog:added]
  • Loading branch information...
cdupuis committed Jun 26, 2019
1 parent ac978ec commit d0701de2fecb730e1ca659913acac771c4ec3b0b
Showing with 15 additions and 0 deletions.
  1. +15 −0 lib/internal/transport/cluster/ClusterMasterRequestProcessor.ts
@@ -496,6 +496,7 @@ export class ClusterMasterRequestProcessor extends AbstractRequestProcessor impl

setInterval(() => {
const messageCount = this.messages.length;
const statsd = (this.configuration.statsd as any).__instance as StatsD;
if (messageCount >= threshold) {
sendMessage({
control: {
@@ -509,11 +510,25 @@ export class ClusterMasterRequestProcessor extends AbstractRequestProcessor impl
logger.info(`Initiated incoming messages backoff. queue size: ${messageCount}, threshold: ${threshold}`);
}
this.backoffInitiated = true;
if (!!statsd) {
statsd.gauge(
"work_queue.backoff",
1,
[],
() => {});
}
} else {
if (this.backoffInitiated) {
logger.info(`Stopped incoming messages backoff. queue size: ${messageCount}, threshold: ${threshold}`);
}
this.backoffInitiated = false;
if (!!statsd) {
statsd.gauge(
"work_queue.backoff",
0,
[],
() => {});
}
}
}, interval).unref();
}

0 comments on commit d0701de

Please sign in to comment.
You can’t perform that action at this time.