Hello, I have a question about the ktor_http_serve...
# ktor
s
Hello, I have a question about the ktor_http_server_requests_seconds_bucket Micrometer metric. We are pretty consistently seeing that it reports 30s for the
Upgrade
of a websocket. Do you have any guidance about the best way to assess why this would report such a large value? We don't appear to see websocket connection errors on our libwebsockets.org based client or within our ktor based server in production. Locally we also see this with just kotlin based clients connecting to our service. We are using Netty if it matters. Using ktor 2.3.0. Is there a particular logger we can turn up to see the activity between ktor and the MicrometerMetrics? I will try to create a minimal example and send a github if I am able to do so. Any assistance would be greatly appreciated.
I realize I neglected to mention I added these to our logging config:
Copy code
io.ktor.websocket: "ALL"
        io.ktor.server: "ALL"
        io.micrometer: "ALL"
but I'm not seeing anything related to this particular Timer or how this metric is started/stopped.
c
would suspect this has something to do with a websocket no longer being http requests - perhaps the transition to websocket is not measured correctly there. Perhaps dig through the code to see where the timing occurs.
s
Thanks! That is my suspicion as well. I'm just not familiar with how Micrometer timers are started in ktor. I will clone the repo and see if I can find something.
The one thing that is curious is that it's not happening for all of the Upgrade but only after a period of activity and some number of websocket sessions have upgraded successfully. I'll update if I find out more.
c
iirc the observability hooks in ktor are based on events (that ktor emits); perhaps something in there that isn’t tracking event state properly etc.
smells a bit like a race condition.