Skip to content

[Proposal] prometheus middleware, configuable status resolver #125

@Lee-Minjea

Description

@Lee-Minjea

Hello.

I have got an proposal on prometheus middleware.

In the project I am working on, we use internally defined errors, which are resolved to status codes at echo HTTPErrorHandler.

Prometheus middleware, as an Echo middleware, runs before HTTPErrorHandler, so it cannot reference the final status code resolved in the Handler or the internally defined errors mentioned earlier.

Here is my proposal:
Add an errorToStatusCodeResolver option to the MiddlewareConfig that resolves error to status code.
Default behavior should remain as it is, referencing echo.HTTPError.

https://github.com/labstack/echo-contrib/blob/master/prometheus/prometheus.go#L426-L434
If users define an additional resolver, it should use that resolver.

If there is an open PR, I will create it.

Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions