parent
9b4ca235dd
commit
7dcbf69536
|
|
@ -58,6 +58,7 @@ type mailer struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type mailerStats struct {
|
type mailerStats struct {
|
||||||
|
sendDelay *prometheus.GaugeVec
|
||||||
nagsAtCapacity *prometheus.GaugeVec
|
nagsAtCapacity *prometheus.GaugeVec
|
||||||
errorCount *prometheus.CounterVec
|
errorCount *prometheus.CounterVec
|
||||||
sendLatency prometheus.Histogram
|
sendLatency prometheus.Histogram
|
||||||
|
|
@ -389,6 +390,12 @@ func (m *mailer) findExpiringCertificates(ctx context.Context) error {
|
||||||
continue // nothing to do
|
continue // nothing to do
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Report the send delay metric. Note: this is the worst-case send delay
|
||||||
|
// of any certificate in this batch because it's based on the first (oldest).
|
||||||
|
sendDelay := expiresIn - certs[0].Expires.Sub(m.clk.Now())
|
||||||
|
m.stats.sendDelay.With(prometheus.Labels{"nag_group": expiresIn.String()}).Set(
|
||||||
|
float64(sendDelay.Truncate(time.Second).Seconds()))
|
||||||
|
|
||||||
processingStarted := m.clk.Now()
|
processingStarted := m.clk.Now()
|
||||||
err = m.processCerts(ctx, certs)
|
err = m.processCerts(ctx, certs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -455,6 +462,14 @@ type Config struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initStats(stats prometheus.Registerer) mailerStats {
|
func initStats(stats prometheus.Registerer) mailerStats {
|
||||||
|
sendDelay := prometheus.NewGaugeVec(
|
||||||
|
prometheus.GaugeOpts{
|
||||||
|
Name: "send_delay",
|
||||||
|
Help: "For the last batch of certificates, difference between the idealized send time and actual send time. Will always be nonzero, bigger numbers are worse",
|
||||||
|
},
|
||||||
|
[]string{"nag_group"})
|
||||||
|
stats.MustRegister(sendDelay)
|
||||||
|
|
||||||
nagsAtCapacity := prometheus.NewGaugeVec(
|
nagsAtCapacity := prometheus.NewGaugeVec(
|
||||||
prometheus.GaugeOpts{
|
prometheus.GaugeOpts{
|
||||||
Name: "nags_at_capacity",
|
Name: "nags_at_capacity",
|
||||||
|
|
@ -510,6 +525,7 @@ func initStats(stats prometheus.Registerer) mailerStats {
|
||||||
stats.MustRegister(accountsNeedingMail)
|
stats.MustRegister(accountsNeedingMail)
|
||||||
|
|
||||||
return mailerStats{
|
return mailerStats{
|
||||||
|
sendDelay: sendDelay,
|
||||||
nagsAtCapacity: nagsAtCapacity,
|
nagsAtCapacity: nagsAtCapacity,
|
||||||
errorCount: errorCount,
|
errorCount: errorCount,
|
||||||
sendLatency: sendLatency,
|
sendLatency: sendLatency,
|
||||||
|
|
|
||||||
|
|
@ -338,6 +338,8 @@ func TestFindExpiringCertificates(t *testing.T) {
|
||||||
err = testCtx.m.findExpiringCertificates(context.Background())
|
err = testCtx.m.findExpiringCertificates(context.Background())
|
||||||
test.AssertNotError(t, err, "Failed to find expiring certs")
|
test.AssertNotError(t, err, "Failed to find expiring certs")
|
||||||
test.AssertEquals(t, len(testCtx.mc.Messages), 0)
|
test.AssertEquals(t, len(testCtx.mc.Messages), 0)
|
||||||
|
test.AssertMetricWithLabelsEquals(t, testCtx.m.stats.sendDelay, prometheus.Labels{"nag_group": "48h0m0s"}, 90000)
|
||||||
|
test.AssertMetricWithLabelsEquals(t, testCtx.m.stats.sendDelay, prometheus.Labels{"nag_group": "192h0m0s"}, 82800)
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeRegistration(sac sapb.StorageAuthorityClient, id int64, jsonKey []byte, contacts []string) (*corepb.Registration, error) {
|
func makeRegistration(sac sapb.StorageAuthorityClient, id int64, jsonKey []byte, contacts []string) (*corepb.Registration, error) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue