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

net.nemerosa.ontrack.model.support.MeterRegistryExtensions.kt Maven / Gradle / Ivy

There is a newer version: 4.4.5
Show newest version
package net.nemerosa.ontrack.model.support

import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.core.instrument.Tag

/**
 * Utility method to record a time metric.
 *
 * @param T Return type of the code to measure
 * @param name Name of the timer
 * @param tags List of tags to associate with the metric.
 * @param code Code whose execution duration must be recorded
 * @return Value returned by the code being measured
 */
fun  MeterRegistry.time(
        name: String,
        vararg tags: Pair,
        code: () -> T
): T {
    val timer = timer(name, tags.map { Tag.of(it.first, it.second) })
    return timer.record(code)!!
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy