hwt/metrics/prom.go

43 lines
953 B
Go
Raw Permalink Normal View History

2018-01-21 14:50:32 -08:00
package metrics
import (
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
)
var (
httpReqLat = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Name: "hwt_request_latency_ms",
Help: "Latency in ms of http requests grouped by req path",
2018-01-26 17:14:53 -08:00
Objectives: map[float64]float64{
0.5: 0.05,
0.9: 0.01,
0.95: 0.001,
0.99: 0.001,
1.0: 0.0001,
},
2018-01-21 14:50:32 -08:00
},
[]string{"path"},
)
2018-01-26 18:05:28 -08:00
httpStatus = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "hwt_http_requests_total",
Help: "How many HTTP requests processed, partitioned by status code and HTTP method.",
},
[]string{"path", "code"},
)
2018-01-21 14:50:32 -08:00
)
func RegisterPromMetrics() error {
if err := prometheus.Register(httpReqLat); err != nil {
return errors.Wrap(err, "registering http request latency")
}
2018-01-26 18:05:28 -08:00
if err := prometheus.Register(httpStatus); err != nil {
return errors.Wrap(err, "registering http request status")
}
2018-01-21 14:50:32 -08:00
return nil
}