Skip to content

Commit

Permalink
metrics: register skipper_filter_create_duration_seconds (#3129)
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexanderYastrebov authored Jun 26, 2024
1 parent 4fee4d3 commit 02515fe
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 02515fe

Please sign in to comment.