"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrometheusExporter = void 0;
const prom_client_1 = __importStar(require("prom-client"));
const metrics_1 = require("./metrics");
const metrics_2 = 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;
        this.registry = new prom_client_1.Registry();
    }
    setTotalPluginImports(totalPluginImports) {
        this.totalPluginImports.counter = totalPluginImports;
        data_fetcher_1.collectMetrics(this.totalPluginImports);
    }
    async getPrometheusMetrics() {
        const result = await this.registry.getSingleMetricAsString(metrics_1.K_CACTUS_API_SERVER_TOTAL_PLUGIN_IMPORTS);
        return result;
    }
    startMetricsCollection() {
        this.registry.registerMetric(metrics_2.totalTxCount);
        prom_client_1.default.collectDefaultMetrics({ register: this.registry });
    }
}
exports.PrometheusExporter = PrometheusExporter;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvbWV0aGV1cy1leHBvcnRlci5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4u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