You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I discovered a weird behaviour if metrics are enabled on an HttpRoutes value that is composed with some other value.
For example let's say there are apiRoutes and adminRoutes defined and compose like this:
valmetrics:MetricsOps[F] =???valapiRoutes:HttpRoutes[F] =???valadminRoutes:HttpRoutes[F] =???valapiRoutesWithMetrics=Metrics[IO](metrics)(apiRoutes)
httpApp = (
apiRoutesWithMetrics <+> adminRoutes. // <+> SemigroupK Cats
).mapF(_.getOrElseF(NotFound()))
return httpApp // <- this is used to create the http4s webserver
Whenever there is a request meant for the adminRoutes the metrics defined for apiRoutesWithMetrics gets incremented for 4xx requests although the request is send back to the client with 200 OK status.
If the routes are composed the other way around adminRoutes <+> apiRoutesWithMetrics this behaviour does not happen.
I'm guessing is because the request goes through the first routes and exists with NotFound (400) and the metrics are incremented and then the request go to the admin routes and there is a route defined but the metrics are already incremented.
I'm not saying it's a bug in the library but maybe there can be added to the documentation.
I'm happy to add it.
What is your opinion on this?
Regards,
Robert
The text was updated successfully, but these errors were encountered:
Hi team,
I discovered a weird behaviour if metrics are enabled on an
HttpRoutes
value that is composed with some other value.For example let's say there are
apiRoutes
andadminRoutes
defined and compose like this:Whenever there is a request meant for the
adminRoutes
the metrics defined forapiRoutesWithMetrics
gets incremented for4xx
requests although the request is send back to the client with 200 OK status.If the routes are composed the other way around
adminRoutes <+> apiRoutesWithMetrics
this behaviour does not happen.I'm guessing is because the request goes through the first routes and exists with
NotFound (400)
and the metrics are incremented and then the request go to the admin routes and there is a route defined but the metrics are already incremented.I'm not saying it's a bug in the library but maybe there can be added to the documentation.
I'm happy to add it.
What is your opinion on this?
Regards,
Robert
The text was updated successfully, but these errors were encountered: