Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥
TypeScript aiai-agentsai-crawlerai-scrapingai-searchcrawlerdata-extractionhtml-to-markdownllmmarkdownscraperscrapingweb-crawlerweb-dataweb-data-extractionweb-scraperweb-scrapingweb-searchwebscraping
chore(api): replace concurrency queue team id labels with total (#2867)
tomsideguideb6fed5b5e630
diff --git a/apps/api/src/controllers/v0/admin/metrics.ts b/apps/api/src/controllers/v0/admin/metrics.tsindex 69d2217f0..b64a839f0 100644--- a/apps/api/src/controllers/v0/admin/metrics.ts+++ b/apps/api/src/controllers/v0/admin/metrics.ts@@ -5,7 +5,8 @@ import { teamConcurrencySemaphore } from "../../../services/worker/team-semaphorexport async function metricsController(_: Request, res: Response) {let cursor: string = "0";- const metrics: Record<string, number> = {};+ let totalJobCount = 0;+ let teamCount = 0;do {const res = await getRedisConnection().sscan("concurrency-limit-queues",@@ -21,8 +22,8 @@ export async function metricsController(_: Request, res: Response) {if (jobCount === 0) {await getRedisConnection().srem("concurrency-limit-queues", key);} else {- const teamId = key.split(":")[1];- metrics[teamId] = jobCount;+ totalJobCount += jobCount;+ teamCount++;}}} while (cursor !== "0");@@ -30,14 +31,13 @@ export async function metricsController(_: Request, res: Response) {const semaphoreMetrics = await teamConcurrencySemaphore.getMetrics();res.contentType("text/plain").send(`\-# HELP concurrency_limit_queue_job_count The number of jobs in the concurrency limit queue per team-# TYPE concurrency_limit_queue_job_count gauge-${Object.entries(metrics)- .map(- ([key, value]) =>- `concurrency_limit_queue_job_count{team_id="${key}"} ${value}`,- )- .join("\n")}+# HELP concurrency_limit_queue_job_count_total The total number of jobs across all concurrency limit queues+# TYPE concurrency_limit_queue_job_count_total gauge+concurrency_limit_queue_job_count_total ${totalJobCount}++# HELP concurrency_limit_queue_team_count The number of teams with jobs in the concurrency limit queue+# TYPE concurrency_limit_queue_team_count gauge+concurrency_limit_queue_team_count ${teamCount}# HELP billed_teams_count The number of teams that have been billed but not yet tallied# TYPE billed_teams_count gauge