Have a question regarding Prometheus metrics in Tapir and ZIO. I have a simple code:
val metrics = PrometheusMetrics.default[Task]()
val options: ZioHttpServerOptions[Any] = ZioHttpServerOptions
.customiseInterceptors
.metricsInterceptor(metrics.metricsInterceptor())
.options
and it works correct when I call localhost:8080/metrics
, I see metrics.
But when I added default error handler:
val metrics = PrometheusMetrics.default[Task]()
def failureResponse(msg: String): ValuedEndpointOutput[_]=
ValuedEndpointOutput(jsonBody[MyFailure], MyFailure(msg))
val options: ZioHttpServerOptions[Any] = ZioHttpServerOptions
.customiseInterceptors
.metricsInterceptor(metrics.metricsInterceptor())
.defaultHandlers(failureResponse, notFoundWhenRejected = true)
.options
It doesn't work. Instead of metrics I see now error (404) which was caught during request to localhost:8080/metrics
. Honestly, don't know why. Is it possible to fix it somehow and keep error handler along with metrics interceptor?
EDIT: Metrics endpoint:
def metricsEndpoint = ZioHttpInterpreter(options).toHttp(metrics.metricsEndpoint)