forked from TrueCloudLab/frostfs-http-gw
added reusable metrics endpoints
This commit is contained in:
parent
1d5c1897a3
commit
ad03a95feb
1 changed files with 13 additions and 0 deletions
13
metrics.go
13
metrics.go
|
@ -3,12 +3,25 @@ package main
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/fasthttp/router"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"github.com/prometheus/common/expfmt"
|
"github.com/prometheus/common/expfmt"
|
||||||
"github.com/valyala/fasthttp"
|
"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 {
|
func metricsHandler(reg prometheus.Gatherer, opts promhttp.HandlerOpts) fasthttp.RequestHandler {
|
||||||
var (
|
var (
|
||||||
inFlightSem chan struct{}
|
inFlightSem chan struct{}
|
||||||
|
|
Loading…
Reference in a new issue