https://kotlinlang.org logo
#ktor
Title
# ktor
h

Helio

11/27/2023, 4:22 AM
Another quick question... But where can I find information about the metric
ktor.http.server.requests.active
apparently this is returning a negative value, so I was curious to figure out how this is calculated.
a

Aleksei Tirman [JB]

11/27/2023, 11:02 AM
Can you please describe your problem in more detail?
h

Helio

11/27/2023, 11:17 AM
Absolutely! So for this one, I was curious to understand a little bit more about the metrics that Ktor expose, such as the one above. For example, looking at the metric, it seems that it is returning a negative value, I'm super curious about why the number of active connections are "decreasing". For example:
Sorry, but also this one.. Not sure if my explanation made sense?
a

Aleksei Tirman [JB]

11/28/2023, 10:38 AM
This metric reflects the number of the current processed requests. It shouldn't be negative. Can you tell me how to reproduce your problem?
h

Helio

11/28/2023, 11:02 AM
I will share with you tomorrow the snippet, but mainly adding the metrics plugin... I don't suppose we make any change.
As promised, this is how we set it:
Copy code
install(MicrometerMetrics) {
        registry = statsdMeterRegistry { configurationParameter ->
            when (configurationParameter) {
                MicrometerMetricConstants.STATSD_HOST -> MicrometerMetricConstants.PLATFORM_STATSD
                else -> null
            }
        }.apply {
            meterBinders = listOf(
                ClassLoaderMetrics(),
                JvmMemoryMetrics(),
                JvmGcMetrics(),
                ProcessorMetrics(),
                JvmThreadMetrics(),
            )
        }
    }