Skip to content

Commit

Permalink
Replace block wait metric with Histogram
Browse files Browse the repository at this point in the history
  • Loading branch information
darunrs committed Nov 21, 2023
1 parent 517616a commit f09a9bb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion runner/src/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import express from 'express';
import { Gauge, Histogram, Counter, AggregatorRegistry } from 'prom-client';

const BLOCK_WAIT_DURATION = new Gauge({
const BLOCK_WAIT_DURATION = new Histogram({
name: 'queryapi_runner_block_wait_duration_milliseconds',
help: 'Time an indexer function waited for a block before processing',
labelNames: ['indexer', 'type'],
buckets: [1, 10, 100, 300, 500, 1000, 3000, 5000, 10000, 30000],
});

const CACHE_HIT = new Counter({
Expand Down
2 changes: 1 addition & 1 deletion runner/src/stream-handler/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ async function blockQueueConsumer (workerContext: WorkerContext, streamKey: stri
console.error('Block failed to process or does not have block height', block);
continue;
}
METRICS.BLOCK_WAIT_DURATION.labels({ indexer: indexerName, type: workerContext.streamType }).set(performance.now() - blockStartTime);
METRICS.BLOCK_WAIT_DURATION.labels({ indexer: indexerName, type: workerContext.streamType }).observe(performance.now() - blockStartTime);
await indexer.runFunctions(block, functions, isHistorical, { provision: true });

await workerContext.redisClient.deleteStreamMessage(streamKey, streamMessageId);
Expand Down

0 comments on commit f09a9bb

Please sign in to comment.