Serve the delivery duration histogram from boot (closes #267)
check / check (push) Successful in 3m25s
check / check (push) Successful in 3m25s
The delivery duration histogram was registered only when a delivery first ran, so until then /metrics had no series for it and a dashboard or alert on it saw nothing at all rather than zero. Each of the four target types now has its series registered at boot with zero counts, so the histogram is served from the first scrape. Tests pin that all four series are present before any delivery, on the metrics registry and through the production router. Model: opus-5-5
This commit was merged in pull request #427.
Šī revīzija ir iekļauta:
@@ -384,6 +384,7 @@ func (s *Set) initSeries() {
|
|||||||
s.deliveriesFailed.WithLabelValues(label)
|
s.deliveriesFailed.WithLabelValues(label)
|
||||||
s.deliveryRetries.WithLabelValues(label)
|
s.deliveryRetries.WithLabelValues(label)
|
||||||
s.deliveryReplays.WithLabelValues(label)
|
s.deliveryReplays.WithLabelValues(label)
|
||||||
|
s.deliveryDuration.WithLabelValues(label)
|
||||||
s.deliveriesPending.WithLabelValues(label)
|
s.deliveriesPending.WithLabelValues(label)
|
||||||
s.deliveriesRetrying.WithLabelValues(label)
|
s.deliveriesRetrying.WithLabelValues(label)
|
||||||
s.circuitBreakersOpen.WithLabelValues(label)
|
s.circuitBreakersOpen.WithLabelValues(label)
|
||||||
|
|||||||
@@ -167,6 +167,7 @@ func TestKnownSeriesExistBeforeAnyDelivery(t *testing.T) {
|
|||||||
"webhooker_deliveries_succeeded_total",
|
"webhooker_deliveries_succeeded_total",
|
||||||
"webhooker_deliveries_failed_total",
|
"webhooker_deliveries_failed_total",
|
||||||
"webhooker_delivery_retries_total",
|
"webhooker_delivery_retries_total",
|
||||||
|
"webhooker_delivery_duration_seconds",
|
||||||
"webhooker_circuit_breakers_open",
|
"webhooker_circuit_breakers_open",
|
||||||
} {
|
} {
|
||||||
assert.ElementsMatch(t,
|
assert.ElementsMatch(t,
|
||||||
|
|||||||
@@ -1580,3 +1580,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`,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Atsaukties uz šo jaunā problēmā
Block a user