"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (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;
        (0, 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,eyJ2ZXJzaW9uIjozLCJmaWxlIj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