All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.infobip.kafkistry.metric.MetricHolder.kt Maven / Gradle / Ivy

The newest version!
package com.infobip.kafkistry.metric

import com.infobip.kafkistry.metric.config.PrometheusMetricsProperties
import java.util.concurrent.ConcurrentHashMap

typealias MetricNamePrefix = String

class MetricHolder(
    private val creator: (MetricNamePrefix) -> T
) {

    private val namePrefixMetric = ConcurrentHashMap()

    fun metric(promProperties: PrometheusMetricsProperties): T {
        return metric(promProperties.prefix)
    }

    fun metric(prefix: MetricNamePrefix): T {
        return namePrefixMetric.computeIfAbsent(prefix, creator)
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy