chore(stdiscosrv): prewarm counters at startup

Signed-off-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
Jakob Borg
2026-05-18 23:40:38 +02:00
parent 4ba01b05a1
commit c17be06192
+27 -8
View File
@@ -7,6 +7,8 @@
package main package main
import ( import (
"net/http"
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
) )
@@ -113,14 +115,11 @@ var (
) )
const ( const (
dbOpGet = "get" dbOpGet = "get"
dbOpPut = "put" dbOpPut = "put"
dbOpMerge = "merge" dbOpMerge = "merge"
dbOpDelete = "delete" dbResSuccess = "success"
dbResSuccess = "success" dbResNotFound = "not_found"
dbResNotFound = "not_found"
dbResError = "error"
dbResUnmarshalError = "unmarsh_err"
) )
func init() { func init() {
@@ -132,4 +131,24 @@ func init() {
databaseOperations, databaseOperationSeconds, databaseOperations, databaseOperationSeconds,
databaseWriteSeconds, databaseLastWritten, databaseWriteSeconds, databaseLastWritten,
retryAfterLevel) retryAfterLevel)
// Prewarm important counters so they're available with zero values at
// startup
apiRequestsTotal.WithLabelValues(http.MethodGet, "200")
apiRequestsTotal.WithLabelValues(http.MethodGet, "404")
apiRequestsTotal.WithLabelValues(http.MethodPost, "204")
apiRequestsTotal.WithLabelValues(http.MethodPost, "400")
apiRequestsTotal.WithLabelValues(http.MethodPost, "403")
lookupRequestsTotal.WithLabelValues("success")
lookupRequestsTotal.WithLabelValues("not_found_ever")
lookupRequestsTotal.WithLabelValues("not_found_recent")
announceRequestsTotal.WithLabelValues("success")
announceRequestsTotal.WithLabelValues("bad_request")
announceRequestsTotal.WithLabelValues("no_certificate")
replicationSendsTotal.WithLabelValues("success")
replicationRecvsTotal.WithLabelValues("success")
} }