From ad03a95feb51d797c95e6ec53420347b66a42f14 Mon Sep 17 00:00:00 2001 From: Evgeniy Kulikov Date: Tue, 3 Mar 2020 13:34:52 +0300 Subject: [PATCH] added reusable metrics endpoints --- metrics.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/metrics.go b/metrics.go index 4829d35..4a7c857 100644 --- a/metrics.go +++ b/metrics.go @@ -3,12 +3,25 @@ package main import ( "fmt" + "github.com/fasthttp/router" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "github.com/prometheus/common/expfmt" "github.com/valyala/fasthttp" ) +func attachMetrics(r *router.Router, z promhttp.Logger) { + r.GET("/metrics/", metricsHandler(prometheus.DefaultGatherer, promhttp.HandlerOpts{ + ErrorLog: z, + //ErrorHandling: 0, + //Registry: nil, + //DisableCompression: false, + //MaxRequestsInFlight: 0, + //Timeout: 0, + //EnableOpenMetrics: false, + })) +} + func metricsHandler(reg prometheus.Gatherer, opts promhttp.HandlerOpts) fasthttp.RequestHandler { var ( inFlightSem chan struct{}