forked from m1ome/narada
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmetrics.go
More file actions
32 lines (27 loc) · 864 Bytes
/
metrics.go
File metadata and controls
32 lines (27 loc) · 864 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package narada
import (
"net/http"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
serverHealthcheckSummary = promauto.NewSummaryVec(
prometheus.SummaryOpts{
Subsystem: "server",
Name: "healthcheck_duration_seconds",
Help: "time elapsed for healthcheck response",
Objectives: map[float64]float64{0.5: 0.05, 0.9: 0.01, 0.99: 0.001},
},
[]string{"server", "code", "method"},
)
)
func withServerHealthcheckSummary(server string, handler http.Handler) http.Handler {
return promhttp.InstrumentHandlerDuration(
serverHealthcheckSummary.MustCurryWith(prometheus.Labels{"server": server}),
handler,
)
}
func NewMetricsInvoke(ms *Multiserver) error {
return ms.Add("metrics", promhttp.Handler())
}