diff options
Diffstat (limited to 'echo/prometheus/prometheus.go')
-rw-r--r-- | echo/prometheus/prometheus.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/echo/prometheus/prometheus.go b/echo/prometheus/prometheus.go index 2fbf252..5f93bea 100644 --- a/echo/prometheus/prometheus.go +++ b/echo/prometheus/prometheus.go | |||
@@ -64,9 +64,19 @@ func NewPrometheusWithConfig(c *PrometheusConfig) *Prometheus { | |||
64 | c.ExtractHost = DefaultPrometheusConfig.ExtractHost | 64 | c.ExtractHost = DefaultPrometheusConfig.ExtractHost |
65 | } | 65 | } |
66 | 66 | ||
67 | // Mostly matches promhttp.Handler implementation | ||
68 | hnd := echo.WrapHandler(promhttp.InstrumentMetricHandler( | ||
69 | prometheus.DefaultRegisterer, | ||
70 | promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{ | ||
71 | // We gzip by default in the echo warpper; with this enabled we | ||
72 | // double gzip metrics and corrupt them | ||
73 | DisableCompression: true, | ||
74 | }), | ||
75 | )) | ||
76 | |||
67 | return &Prometheus{ | 77 | return &Prometheus{ |
68 | Config: c, | 78 | Config: c, |
69 | MetricsHandler: echo.WrapHandler(promhttp.Handler()), | 79 | MetricsHandler: hnd, |
70 | requestCount: promauto.NewCounterVec(prometheus.CounterOpts{ | 80 | requestCount: promauto.NewCounterVec(prometheus.CounterOpts{ |
71 | Subsystem: c.Subsystem, | 81 | Subsystem: c.Subsystem, |
72 | Name: "requests_total", | 82 | Name: "requests_total", |