"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.JobQueueObserversBuilder = void 0;
const tslib_1 = require("tslib");
const job_queue_1 = require("../../job-queue");
class JobQueueObserversBuilder {
    constructor(meter) {
        this.meter = meter;
    }
    buildObservers() {
        this.meter.createObservableGauge('peertube_job_queue_total', {
            description: 'Total jobs in the PeerTube job queue'
        }).addCallback((observableResult) => tslib_1.__awaiter(this, void 0, void 0, function* () {
            const stats = yield job_queue_1.JobQueue.Instance.getStats();
            for (const { jobType, counts } of stats) {
                for (const state of Object.keys(counts)) {
                    observableResult.observe(counts[state], { jobType, state });
                }
            }
        }));
    }
}
exports.JobQueueObserversBuilder = JobQueueObserversBuilder;
//# sourceMappingURL=job-queue-observers-builder.js.map