"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const promClient = require("prom-client");
class PrometheusStatsCounter {
    constructor(metric) {
        this.metric = metric;
    }
    inc(labels, value) {
        this.metric.inc(labels, value);
    }
    reset(labels, value) {
        this.metric.reset();
    }
}
class PrometheusStatsGauge extends PrometheusStatsCounter {
    constructor(gauge) {
        super(gauge);
    }
    dec(labels, value) {
        this.metric.dec(labels, value);
    }
    set(labels, value) {
        this.metric.set(labels, value);
    }
}
class PrometheusStatsHistogram {
    constructor(metric) {
        this.metric = metric;
    }
    observe(labels, value) {
        this.metric.observe(labels, value);
    }
    startTimer(labels) {
        return this.metric.startTimer(labels);
    }
}
class PrometheusStatsSink {
    constructor(config = {}) {
        this.config = config;
        this.metrics = {};
        this.registry = config.registry;
        if (!this.registry) {
            this.registry = new promClient.Registry();
        }
    }
    counter(params) {
        const promParams = Object.assign(params, {
            registers: [this.registry],
        });
        const counter = new PrometheusStatsCounter(new promClient.Counter(promParams));
        this.metrics[params.name] = counter;
        return counter;
    }
    gauge(params) {
        const promParams = Object.assign(params, {
            registers: [this.registry],
        });
        const gauge = new PrometheusStatsGauge(new promClient.Gauge(promParams));
        this.metrics[params.name] = gauge;
        return gauge;
    }
    histogram(params) {
        const promParams = Object.assign(params, {
            registers: [this.registry],
        });
        const histogram = new PrometheusStatsHistogram(new promClient.Histogram(promParams));
        this.metrics[params.name] = histogram;
        return histogram;
    }
    getMetrics() {
        return this.registry.metrics();
    }
}
exports.PrometheusStatsSink = PrometheusStatsSink;
//# sourceMappingURL=PrometheusStatsSink.js.map