From f6d03a0eab04fd2ee27bf695316b2447265a5641 Mon Sep 17 00:00:00 2001 From: Mechiel Lukkien Date: Mon, 11 Sep 2023 11:43:49 +0200 Subject: [PATCH] track more unexpected panics in metrics --- smtpserver/server.go | 4 +++- webaccount/import.go | 3 +++ webadmin/admin.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/smtpserver/server.go b/smtpserver/server.go index 95d4bd0..e458275 100644 --- a/smtpserver/server.go +++ b/smtpserver/server.go @@ -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() diff --git a/webaccount/import.go b/webaccount/import.go index a886863..800a690 100644 --- a/webaccount/import.go +++ b/webaccount/import.go @@ -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") } }() diff --git a/webadmin/admin.go b/webadmin/admin.go index 9e1f725..a006e80 100644 --- a/webadmin/admin.go +++ b/webadmin/admin.go @@ -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.