r/ktor•
markmcw

Micrometer route tag

Hello.

We've just implemented Micrometer into our Ktor application and it works a treat giving us some great Prometheus Metrics. However, I've spotted something really odd with the `route` tag that it's passing back to us for our metrics.

In some cases where we have csrf protection disabled, it's setting the route tag to `route="/org.mpierce.ktor.csrf.CsrfRouteSelector@67405442/liveness"`

We're not doing anything overly special to declare the route, just wrapping it in `noCsrfProtection`.

I believe this is the code https://github.com/ktorio/ktor/blob/92f4e96b6f863ffbfc3f6afae52a8ac584a2be3b/ktor-features/ktor-metrics-micrometer/jvm/src/io/ktor/metrics/micrometer/MicrometerMetrics.kt#L142 where Micrometer fetches the route. Does anyone have any suggestions on how we stop our routes from getting littered with extra content and just outputs the expected `/liveness`?

Posted Sep 3, 2021, 9:51 AM UTC

11
8bitlives•

Looks like the CsrfRouteSelector would be used as part of the route string, but it missed a toString() implementation thus only resulting in the default of typename & address string literal

1