Skip to content

Commit cf67b8a

Browse files
committed
Add batch_queue.rate_limit_denied counter metric
1 parent 3a3227d commit cf67b8a

File tree

1 file changed

+7
-0
lines changed
  • internal-packages/run-engine/src/batch-queue

1 file changed

+7
-0
lines changed

internal-packages/run-engine/src/batch-queue/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export class BatchQueue {
8989
private batchProcessingDurationHistogram?: Histogram;
9090
private itemQueueTimeHistogram?: Histogram;
9191
private workerQueueLengthGauge?: ObservableGauge;
92+
private rateLimitDeniedCounter?: Counter;
9293

9394
constructor(private options: BatchQueueOptions) {
9495
this.logger = options.logger ?? new Logger("BatchQueue", options.logLevel ?? "info");
@@ -612,6 +613,11 @@ export class BatchQueue {
612613
unit: "ms",
613614
});
614615

616+
this.rateLimitDeniedCounter = meter.createCounter("batch_queue.rate_limit_denied", {
617+
description: "Number of times the global rate limiter denied processing",
618+
unit: "denials",
619+
});
620+
615621
this.workerQueueLengthGauge = meter.createObservableGauge("batch_queue.worker_queue.length", {
616622
description: "Number of items waiting in the batch worker queue",
617623
unit: "items",
@@ -653,6 +659,7 @@ export class BatchQueue {
653659
if (result.allowed) {
654660
break;
655661
}
662+
this.rateLimitDeniedCounter?.add(1);
656663
const waitMs = Math.max(0, (result.resetAt ?? Date.now()) - Date.now());
657664
if (waitMs > 0) {
658665
await new Promise<void>((resolve, reject) => {

0 commit comments

Comments
 (0)