Skip to content

Commit

Permalink
fix(metrics): Disable compression on prometheus/client_golang's handler
Browse files Browse the repository at this point in the history
Fixes #406

Root cause seems to be that promhttp.Handler() has its own gzip compression prometheus/client_golang#622
  • Loading branch information
TwiN committed Jan 20, 2023
1 parent 90bb8f7 commit 24e207c
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion controller/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import (
static "github.com/TwiN/gatus/v5/web"
"github.com/TwiN/health"
"github.com/gorilla/mux"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)

func CreateRouter(cfg *config.Config) *mux.Router {
router := mux.NewRouter()
if cfg.Metrics {
router.Handle("/metrics", promhttp.Handler()).Methods("GET")
router.Handle("/metrics", promhttp.InstrumentMetricHandler(prometheus.DefaultRegisterer, promhttp.HandlerFor(prometheus.DefaultGatherer, promhttp.HandlerOpts{
DisableCompression: true,
}))).Methods("GET")
}
router.Use(GzipHandler)
api := router.PathPrefix("/api").Subrouter()
Expand Down

0 comments on commit 24e207c

Please sign in to comment.