Kotlin support for micrometer.io.
repositories {
mavenCentral() // jcenter()
}
dependencies {
implementation group: 'com.oripwk', name: 'micrometer-kotlin', version: '0.1'
// OR
implementation group: 'com.oripwk', name: 'micrometer-kotlin', version: '0.1.kotlin12'
}
val meterRegistry = SimpleMeterRegistry()
val myTimer = meterRegistry.coTimer("my-timer")
val result: Int = myTimer.record {
GlobalScope.async { 42 }.await()
}
The API is fully compatible with Timer.builder(…)
API, leveraging Kotlin's default parameters constructor:
Timer
.builder("my-timer")
.coTimer(
meterRegistry = SimpleMeterRegistry(),
tags = listOf(Tag.of("env", "dev")),
maximumExpectedValue = Duration.ofSeconds(1)
// …
)