diff --git a/go.mod b/go.mod index 029dca0..e5874a9 100644 --- a/go.mod +++ b/go.mod @@ -5,6 +5,7 @@ go 1.16 require ( github.com/labstack/echo/v4 v4.6.1 github.com/labstack/gommon v0.3.1 + github.com/pkg/errors v0.9.1 github.com/prometheus/client_golang v1.11.0 github.com/sirupsen/logrus v1.8.1 ) diff --git a/go.sum b/go.sum index 0b8d442..eeb5456 100644 --- a/go.sum +++ b/go.sum @@ -77,6 +77,7 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= diff --git a/middleware/prometheus.go b/middleware/prometheus.go index 427d424..1e27be1 100644 --- a/middleware/prometheus.go +++ b/middleware/prometheus.go @@ -7,6 +7,7 @@ import ( "github.com/labstack/echo/v4" "github.com/labstack/echo/v4/middleware" + "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" ) @@ -65,7 +66,7 @@ func PrometheusWithConfig(config PrometheusConfig) (echo.MiddlewareFunc, error) requestHistogram := prometheus.NewHistogramVec(config.HistogramOpts, []string{"status", "path"}) err := config.Registerer.Register(requestHistogram) if err != nil { - return nil, err + return nil, errors.Wrap(err, "Failed to register request histogram") } return func(next echo.HandlerFunc) echo.HandlerFunc {