mirror of
https://github.com/mjl-/mox.git
synced 2025-07-12 17:04:39 +03:00
Fail tests if unhandled panics happened.
We normally recover from those situations, printing stack traces instead of crashing the program. But during tests, we're not looking at the prometheus metrics or all the output. Without these checks, such panics could go unnoticed. Seems like a reasonable thing to add, unhandled panics haven't been encountered in tests.
This commit is contained in:
@ -1,6 +1,8 @@
|
||||
package metrics
|
||||
|
||||
import (
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
"github.com/prometheus/client_golang/prometheus/promauto"
|
||||
)
|
||||
@ -72,6 +74,9 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
var Panics atomic.Int64
|
||||
|
||||
func PanicInc(name Panic) {
|
||||
Panics.Add(1)
|
||||
metricPanic.WithLabelValues(string(name)).Inc()
|
||||
}
|
||||
|
Reference in New Issue
Block a user