1
0
Fork 0
mirror of https://github.com/Luzifer/badge-gen.git synced 2024-11-08 21:30:02 +00:00
badge-gen/metrics.go

39 lines
1.1 KiB
Go
Raw Normal View History

2016-07-07 13:24:33 +00:00
package main
import "github.com/prometheus/client_golang/prometheus"
var (
requestCount *prometheus.CounterVec
requestDuration *prometheus.SummaryVec
responseSize *prometheus.SummaryVec
)
func init() {
initMetrics()
}
func initMetrics() {
so := prometheus.SummaryOpts{
Subsystem: "badge_gen",
}
reqCnt := prometheus.NewCounterVec(prometheus.CounterOpts{
Subsystem: so.Subsystem,
Name: "requests_total",
Help: "Total number of HTTP requests made.",
ConstLabels: so.ConstLabels,
}, []string{"handler", "method", "code"})
so.Name = "response_size_bytes"
so.Help = "The HTTP response sizes in bytes."
resSz := prometheus.NewSummaryVec(so, []string{"handler"})
so.Name = "request_duration_microseconds"
so.Help = "The HTTP request latencies in microseconds."
reqDur := prometheus.NewSummaryVec(so, []string{"handler"})
requestCount = prometheus.MustRegisterOrGet(reqCnt).(*prometheus.CounterVec)
requestDuration = prometheus.MustRegisterOrGet(reqDur).(*prometheus.SummaryVec)
responseSize = prometheus.MustRegisterOrGet(resSz).(*prometheus.SummaryVec)
}