"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PrometheusFactory = exports.createPrometheusConfig = void 0;
/**
 * Create a prometheus configuration from the environment
 *
 * @param env - the environment variables
 *
 * @return the prometheus configuration
 */
function createPrometheusConfig(env, hostname) {
    return {
        hostname: env.PROM_HOST,
        instance: hostname,
        port: +(env.PROM_PORT || 0),
        env: process.env.NODE_ENV,
        push_interval_ms: +(process.env.PROM_PUSH_INTERVAL_MS || 10000),
        buckets_start: +(process.env.PROM_BUCKETS_START || 0),
        buckets_width: +(process.env.PROM_BUCKETS_WIDTH || 10),
        buckets_count: +(process.env.PROM_BUCKETS_COUNT || 10),
    };
}
exports.createPrometheusConfig = createPrometheusConfig;
var PrometheusFactory = /** @class */ (function () {
    function PrometheusFactory() {
    }
    /**
     * Create a PushGateway
     *
     * @param client   - prometheus client
     * @param hostname - push gateway url
     * @param port     - push gateway port
     *
     * @return the gateway
     */
    PrometheusFactory.prototype.createGateway = function (client, hostname, port) {
        var url = 'http://' + hostname + ':' + port;
        return new client.Pushgateway(url);
    };
    /**
     * Create a histogram metric
     *
     * @param client       - prometheus client
     * @param name         - metric name
     * @param help         - a description of the metric
     * @param bucket_start - where to start the range of buckets
     * @param bucket_width - the size of each bucket
     * @param bucket_count - the total number of buckets
     *
     * @return the metric
     */
    PrometheusFactory.prototype.createHistogram = function (client, name, help, bucket_start, bucket_width, bucket_count) {
        return new client.Histogram({
            name: name,
            help: help,
            buckets: client.linearBuckets(bucket_start, bucket_width, bucket_count),
        });
    };
    /**
     * Create a counter metric
     *
     * @param client       - prometheus client
     * @param name         - metric name
     * @param help         - a description of the metric
     *
     * @return the metric
     */
    PrometheusFactory.prototype.createCounter = function (client, name, help) {
        return new client.Counter({
            name: name,
            help: help,
        });
    };
    /**
     * Create a gauge metric
     *
     * @param client       - prometheus client
     * @param name         - metric name
     * @param help         - a description of the metric
     *
     * @return the metric
     */
    PrometheusFactory.prototype.createGauge = function (client, name, help) {
        return new client.Gauge({
            name: name,
            help: help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