Skip to content

Commit

Permalink
metrics: register skipper_filter_create_duration_seconds
Browse files Browse the repository at this point in the history
Follow up on #3115

Signed-off-by: Alexander Yastrebov <[email protected]>
  • Loading branch information
AlexanderYastrebov committed Jun 26, 2024
1 parent 87d5b6b commit 0d98653
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions metrics/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
23 changes: 23 additions & 0 deletions metrics/prometheus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 0d98653

Please sign in to comment.