diff options
author | Matt Godbolt <matt@godbolt.org> | 2022-10-05 22:01:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-05 22:01:31 -0500 |
commit | f1fa016b102925ad4f1bdeb10cd57fc84949c964 (patch) | |
tree | 49c4c45e73378707ef8626ca62565a3408fe817a /lib/compilation-queue.js | |
parent | 1b762ebe6406215658e41decce61a62f6aa01f89 (diff) | |
download | compiler-explorer-gh-4416.tar.gz compiler-explorer-gh-4416.zip |
Add stats for queue (#4117)gh-4416
Diffstat (limited to 'lib/compilation-queue.js')
-rw-r--r-- | lib/compilation-queue.js | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/compilation-queue.js b/lib/compilation-queue.js index 394d89748..f8e017632 100644 --- a/lib/compilation-queue.js +++ b/lib/compilation-queue.js @@ -25,6 +25,22 @@ import {executionAsyncId} from 'async_hooks'; import {default as Queue} from 'p-queue'; +import PromClient from 'prom-client'; + +// globals as essentially the compilation queue is a singleton, and if we make them members of the queue, tests fail as +// when we create a second queue, the previous counters are still registered. +const queueEnqueued = new PromClient.Counter({ + name: 'ce_compilation_queue_enqueued_total', + help: 'Total number of jobs enqueued', +}); +const queueDequeued = new PromClient.Counter({ + name: 'ce_compilation_queue_dequeued_total', + help: 'Total number of jobs dequeued', +}); +const queueCompleted = new PromClient.Counter({ + name: 'ce_compilation_queue_completed_total', + help: 'Total number of jobs completed', +}); export class CompilationQueue { constructor(concurrency, timeout) { @@ -45,7 +61,9 @@ export class CompilationQueue { // If we're asked to enqueue a job when we're already in a async queued job context, just run it. // This prevents a deadlock. if (this._running.has(enqueueAsyncId)) return job(); + queueEnqueued.inc(); return this._queue.add(() => { + queueDequeued.inc(); const jobAsyncId = executionAsyncId(); if (this._running.has(jobAsyncId)) throw new Error('somehow we entered the context twice'); try { @@ -53,6 +71,7 @@ export class CompilationQueue { return job(); } finally { this._running.delete(jobAsyncId); + queueCompleted.inc(); } }); } |