track more unexpected panics in metrics

This commit is contained in:
Mechiel Lukkien 2023-09-11 11:43:49 +02:00
parent a5006a9090
commit f6d03a0eab
No known key found for this signature in database
3 changed files with 7 additions and 2 deletions

View file

@ -1903,6 +1903,7 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
if x != nil {
c.log.Error("dkim verify panic", mlog.Field("err", x))
debug.PrintStack()
metrics.PanicInc("dkimverify")
}
}()
defer wg.Done()
@ -1936,8 +1937,9 @@ func (c *conn) deliver(ctx context.Context, recvHdrFor func(string) string, msgW
defer func() {
x := recover() // Should not happen, but don't take program down if it does.
if x != nil {
c.log.Error("dkim verify panic", mlog.Field("err", x))
c.log.Error("spf verify panic", mlog.Field("err", x))
debug.PrintStack()
metrics.PanicInc("spfverify")
}
}()
defer wg.Done()

View file

@ -26,6 +26,7 @@ import (
"github.com/mjl-/bstore"
"github.com/mjl-/mox/message"
"github.com/mjl-/mox/metrics"
"github.com/mjl-/mox/mlog"
"github.com/mjl-/mox/mox-"
"github.com/mjl-/mox/store"
@ -68,6 +69,7 @@ func ImportManage() {
if x := recover(); x != nil {
log.Error("import manage panic", mlog.Field("err", x))
debug.PrintStack()
metrics.PanicInc("importmanage")
}
}()
@ -343,6 +345,7 @@ func importMessages(ctx context.Context, log *mlog.Log, token string, acc *store
} else {
log.Error("import panic", mlog.Field("err", x))
debug.PrintStack()
metrics.PanicInc("importmessages")
}
}()

View file

@ -363,7 +363,7 @@ func logPanic(ctx context.Context) {
log := xlog.WithContext(ctx)
log.Error("recover from panic", mlog.Field("panic", x))
debug.PrintStack()
metrics.PanicInc("http")
metrics.PanicInc("webadmin")
}
// return IPs we may be listening on.