Serve the delivery duration histogram from boot (closes #267)
check / check (push) Successful in 3m23s
check / check (push) Successful in 3m23s
webhooker_delivery_duration_seconds was absent from /metrics until the first delivery, while every other delivery series is materialised at zero when the collectors are registered. initSeries now materialises the histogram too, for the same four target types, so a scrape of an instance that has delivered nothing shows it with a zero count and sum. The registration test lists it with the other series, and a new route test scrapes /metrics on a freshly built instance and finds it for every target type. Model: opus-5-5
This commit is contained in:
@@ -1576,3 +1576,31 @@ func TestTwoMetricsRoutersInOneProcess(t *testing.T) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TestMetricsScrapeBeforeAnyDelivery pins
|
||||
// https://git.eeqj.de/sneak/webhooker/issues/267: an instance that
|
||||
// has delivered nothing must still serve the delivery duration
|
||||
// histogram, at zero, for every target type.
|
||||
func TestMetricsScrapeBeforeAnyDelivery(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
env := newTestEnvWithConfig(
|
||||
t, metricsConfig(t, metricsUser, metricsAuthValue),
|
||||
)
|
||||
|
||||
scrape := env.metricsRequest(metricsUser, metricsAuthValue)
|
||||
require.Equal(t, http.StatusOK, scrape.Code)
|
||||
|
||||
for _, targetType := range []database.TargetType{
|
||||
database.TargetTypeHTTP,
|
||||
database.TargetTypeDatabase,
|
||||
database.TargetTypeLog,
|
||||
database.TargetTypeSlack,
|
||||
} {
|
||||
assert.Contains(
|
||||
t, scrape.Body.String(),
|
||||
`webhooker_delivery_duration_seconds_count{target_type="`+
|
||||
string(targetType)+`"} 0`,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user