Skip to content

Commit

Permalink
Merge pull request #245 from fenngwd/feature/log-sentry
Browse files Browse the repository at this point in the history
feature(log): log panic stack trace to stdout in sentry recovery
  • Loading branch information
HeathLee authored Nov 13, 2020
2 parents 170fdb2 + a2c7fb5 commit fbda74c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions extensions/sentryext/grpc/mw.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package sentrygrpcmw
import (
"context"
"errors"
"log"
"runtime/debug"

"github.com/getsentry/sentry-go"
"github.com/grpc-ecosystem/go-grpc-middleware/recovery"
Expand All @@ -15,6 +17,10 @@ import (
func GetOption(d *sentryext.SentryExt) grpc_recovery.Option {
return grpc_recovery.WithRecoveryHandlerContext(
func(ctx context.Context, err interface{}) error {
// log err and stack trace to stdout
log.Println(err)
log.Println(string(debug.Stack()))

hub := sentry.CurrentHub().Clone()
if hub == nil {
return errors.New("failed to get sentry hub")
Expand Down

0 comments on commit fbda74c

Please sign in to comment.