Skip to content

Commit

Permalink
Add statsd metric to indicate WS backoff
Browse files Browse the repository at this point in the history
[changelog:added]
  • Loading branch information
cdupuis committed Jun 26, 2019
1 parent ac978ec commit d0701de
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/internal/transport/cluster/ClusterMasterRequestProcessor.ts
Expand Up @@ -496,6 +496,7 @@ export class ClusterMasterRequestProcessor extends AbstractRequestProcessor impl


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

0 comments on commit d0701de

Please sign in to comment.