2023-01-30 16:27:06 +03:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
|
|
)
|
|
|
|
|
|
|
|
var metricPanic = promauto.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Name: "mox_panic_total",
|
|
|
|
Help: "Number of unhandled panics, by package.",
|
|
|
|
},
|
|
|
|
[]string{
|
|
|
|
"pkg",
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
2023-09-15 17:47:17 +03:00
|
|
|
type Panic string
|
|
|
|
|
|
|
|
const (
|
|
|
|
Ctl Panic = "ctl"
|
|
|
|
Import Panic = "import"
|
|
|
|
Serve Panic = "serve"
|
|
|
|
Imapserver Panic = "imapserver"
|
2023-11-01 19:55:40 +03:00
|
|
|
Dmarcdb Panic = "dmarcdb"
|
2023-09-15 17:47:17 +03:00
|
|
|
Mtastsdb Panic = "mtastsdb"
|
|
|
|
Queue Panic = "queue"
|
|
|
|
Smtpclient Panic = "smtpclient"
|
|
|
|
Smtpserver Panic = "smtpserver"
|
|
|
|
Dkimverify Panic = "dkimverify"
|
|
|
|
Spfverify Panic = "spfverify"
|
|
|
|
Upgradethreads Panic = "upgradethreads"
|
|
|
|
Importmanage Panic = "importmanage"
|
|
|
|
Importmessages Panic = "importmessages"
|
|
|
|
Webadmin Panic = "webadmin"
|
|
|
|
Webmailsendevent Panic = "webmailsendevent"
|
|
|
|
Webmail Panic = "webmail"
|
|
|
|
Webmailrequest Panic = "webmailrequest"
|
|
|
|
Webmailquery Panic = "webmailquery"
|
|
|
|
Webmailhandle Panic = "webmailhandle"
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
// Ensure the panic counts are initialized to 0, so the query for change also picks
|
|
|
|
// up the first panic.
|
|
|
|
names := []Panic{
|
|
|
|
Ctl,
|
|
|
|
Import,
|
|
|
|
Serve,
|
|
|
|
Imapserver,
|
|
|
|
Mtastsdb,
|
|
|
|
Queue,
|
|
|
|
Smtpclient,
|
|
|
|
Smtpserver,
|
|
|
|
Dkimverify,
|
|
|
|
Spfverify,
|
|
|
|
Upgradethreads,
|
|
|
|
Importmanage,
|
|
|
|
Importmessages,
|
|
|
|
Webadmin,
|
|
|
|
Webmailsendevent,
|
|
|
|
Webmail,
|
|
|
|
Webmailrequest,
|
|
|
|
Webmailquery,
|
|
|
|
Webmailhandle,
|
|
|
|
}
|
|
|
|
for _, name := range names {
|
|
|
|
metricPanic.WithLabelValues(string(name)).Add(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func PanicInc(name Panic) {
|
|
|
|
metricPanic.WithLabelValues(string(name)).Inc()
|
2023-01-30 16:27:06 +03:00
|
|
|
}
|