Add request_duration_seconds metric
This commit is contained in:
24
metrics.go
24
metrics.go
@@ -17,7 +17,7 @@ const metricNamespace = "rushlink"
|
||||
// metricURLsTotalGauge counts the number of requests that are handled by
|
||||
// the application, partitioned by status code and HTTP method.
|
||||
//
|
||||
// This counter is updated by throughout the application.
|
||||
// This counter is updated by the router.
|
||||
var metricRequestsTotalCounter = prometheus.NewCounterVec(
|
||||
prometheus.CounterOpts{
|
||||
Namespace: metricNamespace,
|
||||
@@ -26,6 +26,27 @@ var metricRequestsTotalCounter = prometheus.NewCounterVec(
|
||||
Help: "How many HTTP requests processed, partitioned by status code and HTTP method.",
|
||||
}, []string{"code", "method"})
|
||||
|
||||
// metricRequestsLatencyNanoSeconds keeps track of the request latencies for
|
||||
// each http request.
|
||||
//
|
||||
// This historogram is updated by the router.
|
||||
var metricRequestsLatencyNanoSeconds = prometheus.NewHistogramVec(
|
||||
prometheus.HistogramOpts{
|
||||
Namespace: metricNamespace,
|
||||
Subsystem: "http",
|
||||
Name: "request_duration_seconds",
|
||||
Buckets: []float64{
|
||||
float64(500e-6),
|
||||
float64(1e-3),
|
||||
float64(2e-3),
|
||||
float64(5e-3),
|
||||
float64(10e-3),
|
||||
float64(20e-3),
|
||||
float64(50e-3),
|
||||
},
|
||||
Help: "The latency of each HTTP request, partitioned by status code and HTTP method.",
|
||||
}, []string{"code", "method"})
|
||||
|
||||
// metricURLsTotalGauge measures the amount of pastes stored in the database,
|
||||
// partitioned by type and state.
|
||||
//
|
||||
@@ -41,6 +62,7 @@ var metricURLsTotalGauge = prometheus.NewGaugeVec(
|
||||
// StartMetricsServer starts sering Prometheus metrics exports on addr
|
||||
func StartMetricsServer(addr string, database *db.Database, fs *db.FileStore) {
|
||||
prometheus.MustRegister(metricRequestsTotalCounter)
|
||||
prometheus.MustRegister(metricRequestsLatencyNanoSeconds)
|
||||
prometheus.MustRegister(metricURLsTotalGauge)
|
||||
|
||||
router := mux.NewRouter()
|
||||
|
||||
Reference in New Issue
Block a user