xenomachina
12/06/2023, 9:18 PMMicrometerMetrics
plugin, and seeing some pretty weird results from the ktor.http.server.requests.active
metric.
Looking at the code, I believe it's supposed to be a gauge that shows the current number of requests being handled. So if the service is idle, it'l go down to 0, ang generally it'll always be a non-negative integer moving up and down.
However, what we're seeing is a graph that just increases until the server is restarted, at which point it drops back to 0.
I'm wondering if this could be a bug in the implementation of ktor.http.server.requests.active
, or if we've got some kind of configuration error causing this, or if I'm just misunderstanding what this metric is supposed to be.
Does anyone else use this metric, and if so does it look like this?Helio
12/07/2023, 7:41 AMAleksei Tirman [JB]
12/07/2023, 9:00 AMval reg = SimpleMeterRegistry()
embeddedServer(Netty, port = 5555) {
install(MicrometerMetrics) {
registry = reg
}
routing {
get {
call.respondText { reg.get("ktor.http.server.requests.active").gauge().value().toString() }
}
}
}.start(wait = true)
I did the test with ab
and none of them showed a negative value:
ab -n 5000 -c 32 -v 4 <http://localhost:5555/>
Can you tell me how to reproduce the bug?xenomachina
12/07/2023, 10:30 PMval metricsBinders = listOf(
ClassLoaderMetrics(),
JvmGcMetrics(),
JvmInfoMetrics(),
JvmMemoryMetrics(),
JvmThreadMetrics(),
FileDescriptorMetrics(),
ProcessorMetrics()
)
...
install(MicrometerMetrics) {
registry = metricsRegistry
meterBinders = metricsBinders
}
We used to be using a DatadogMeterRegistry
and now we're using a StatsdMeterRegistry
, but we see the same odd behavior with either: the ktor.http.server.requests.active
metric continually increases until the server restarts, at which point it drops to zero before rising again.
We have other gauge metrics (like those created by JvmMemoryMetrics
and JvmThreadMetrics
), and they all behave as expected, with the values they report rising and falling over time: