Hi,
Any ideas on how to implement JVM metrics with tapir? So far, I’ve come up with this
object MetricsRouter:
private val registry = PrometheusRegistry.defaultRegistry
private val threadDemonCount = Metric[IO, Gauge](
metric = Gauge.builder().name("jvm_threads_daemon_count").help("...").register(registry),
onRequest = { (_, gauge, m) =>
m.unit(
EndpointMetric().onResponseBody((_, _) => IO(gauge.set(ManagementFactory.getThreadMXBean.getDaemonThreadCount)))
)
}
)
val Metrics: PrometheusMetrics[IO] =
PrometheusMetrics
.default[IO]()
.addCustom(threadDemonCount)
Many thanks!