"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrometheusExporter = void 0;
const prom_client_1 = __importDefault(require("prom-client"));
const metrics_1 = require("./metrics");
const data_fetcher_1 = require("./data-fetcher");
class PrometheusExporter {
    constructor(prometheusExporterOptions) {
        this.prometheusExporterOptions = prometheusExporterOptions;
        this.totalPluginImports = { counter: 0 };
        this.metricsPollingIntervalInMin =
            prometheusExporterOptions.pollingIntervalInMin || 1;
    }
    setTotalPluginImports(totalPluginImports) {
        this.totalPluginImports.counter = totalPluginImports;
        data_fetcher_1.collectMetrics(this.totalPluginImports);
    }
    async getPrometheusMetrics() {
        const result = await prom_client_1.default.register.getSingleMetricAsString(metrics_1.K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS);
        return result;
    }
    startMetricsCollection() {
        const Registry = prom_client_1.default.Registry;
        const register = new Registry();
        prom_client_1.default.collectDefaultMetrics({ register });
    }
}
exports.PrometheusExporter = PrometheusExporter;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvbWV0aGV1cy1leHBvcnRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uL3NyYy9tYWluL3R5cGVzY3JpcHQvcHJvbWV0aGV1cy1leHBvcnRlci9wcm9tZXRoZXVzLWV4cG9ydGVyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7Ozs7OztBQUFBLDhEQUFxQztBQUVyQyx1Q0FBcUU7QUFDckUsaURBQWdEO0FBTWhELE1BQWEsa0JBQWtCO0lBSTdCLFlBQ2tCLHlCQUFxRDtRQUFyRCw4QkFBeUIsR0FBekIseUJBQXlCLENBQTRCO1FBSHZELHVCQUFrQixHQUF1QixFQUFFLE9BQU8sRUFBRSxDQUFDLEVBQUUsQ0FBQztRQUt0RSxJQUFJLENBQUMs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