Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add worker count metric #439

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion runner/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { startServer as startMetricsServer } from './metrics';
import { METRICS, registerWorkerMetrics, startServer as startMetricsServer } from './metrics';
import RedisClient from './redis-client';
import StreamHandler from './stream-handler';
import promClient from 'prom-client';

const redisClient = new RedisClient();

Expand All @@ -18,6 +19,9 @@ void (async function main () {

while (true) {
const streamKeys = await redisClient.getStreams();
METRICS.WORKER_THREAD_COUNT.set(streamKeys.length);
const metrics = await promClient.register.getMetricsAsJSON();
registerWorkerMetrics(0, metrics as any);

streamKeys.forEach((streamKey) => {
if (streamHandlers[streamKey] !== undefined) {
Expand Down
6 changes: 6 additions & 0 deletions runner/src/metrics.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
import express from 'express';
import { Gauge, Histogram, Counter, AggregatorRegistry } from 'prom-client';

const WORKER_THREAD_COUNT = new Gauge({
name: 'queryapi_runner_worker_thread_count',
help: 'Number of worker threads',
});

const BLOCK_WAIT_DURATION = new Histogram({
name: 'queryapi_runner_block_wait_duration_milliseconds',
help: 'Time an indexer function waited for a block before processing',
Expand Down Expand Up @@ -37,6 +42,7 @@ const EXECUTION_DURATION = new Histogram({
});

export const METRICS = {
WORKER_THREAD_COUNT,
BLOCK_WAIT_DURATION,
CACHE_HIT,
CACHE_MISS,
Expand Down