diff --git a/metrics/prometheus.go b/metrics/prometheus.go index a013d0a259..1126759317 100644 --- a/metrics/prometheus.go +++ b/metrics/prometheus.go @@ -280,6 +280,7 @@ func (p *Prometheus) registerMetrics() { p.registry.MustRegister(p.routeLookupM) p.registry.MustRegister(p.responseM) p.registry.MustRegister(p.routeErrorsM) + p.registry.MustRegister(p.filterCreateM) p.registry.MustRegister(p.filterRequestM) p.registry.MustRegister(p.filterAllRequestM) p.registry.MustRegister(p.filterAllCombinedRequestM) diff --git a/metrics/prometheus_test.go b/metrics/prometheus_test.go index 0aa6574c9e..3c4cc81dce 100644 --- a/metrics/prometheus_test.go +++ b/metrics/prometheus_test.go @@ -73,6 +73,29 @@ func TestPrometheusMetrics(t *testing.T) { }, expCode: http.StatusOK, }, + { + name: "Filter creation latency", + addMetrics: func(pm *metrics.Prometheus) { + pm.MeasureFilterCreate("filter1", time.Now().Add(-15*time.Millisecond)) + }, + expMetrics: []string{ + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="0.005"} 0`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="0.01"} 0`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="0.025"} 1`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="0.05"} 1`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="0.1"} 1`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="0.25"} 1`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="0.5"} 1`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="1"} 1`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="2.5"} 1`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="5"} 1`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="10"} 1`, + `skipper_filter_create_duration_seconds_bucket{filter="filter1",le="+Inf"} 1`, + `skipper_filter_create_duration_seconds_sum{filter="filter1"} 0.015`, + `skipper_filter_create_duration_seconds_count{filter="filter1"} 1`, + }, + expCode: http.StatusOK, + }, { name: "Measuring the filter requests should get the duration of the filter requests.", addMetrics: func(pm *metrics.Prometheus) {