change: integrate sentry sdk for panic reporting and analysis

This commit is contained in:
debugtalk
2022-03-24 19:46:21 +08:00
parent 90c7ba7364
commit 62b21dab22
6 changed files with 172 additions and 3 deletions

View File

@@ -1,9 +1,24 @@
package main
import (
"os"
"time"
"github.com/getsentry/sentry-go"
"github.com/rs/zerolog/log"
"github.com/httprunner/httprunner/hrp/cmd"
)
func main() {
defer func() {
if err := recover(); err != nil {
// report panic to sentry
sentry.CurrentHub().Recover(err)
sentry.Flush(time.Second * 5)
log.Error().Interface("err", err).Msg("recover panic")
os.Exit(1)
}
}()
cmd.Execute()
}