From 1f9d3657e3e89fadef9a46288d9c29a86d8ebb0b Mon Sep 17 00:00:00 2001 From: Mohamad mehdi Kharatizadeh Date: Sat, 5 Jan 2019 21:23:42 +0330 Subject: [PATCH 1/2] use runtime.Frame instead of program counters after braking change to github.com/pkg/errors See [Issue](https://github.com/evalphobia/logrus_sentry/issues/74) --- sentry.go | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sentry.go b/sentry.go index 2a5c388..4001dfe 100644 --- a/sentry.go +++ b/sentry.go @@ -3,7 +3,6 @@ package logrus_sentry import ( "encoding/json" "fmt" - "runtime" "sync" "time" @@ -310,11 +309,9 @@ func (hook *SentryHook) convertStackTrace(st errors.StackTrace) *raven.Stacktrac stConfig := &hook.StacktraceConfiguration stFrames := []errors.Frame(st) frames := make([]*raven.StacktraceFrame, 0, len(stFrames)) - for i := range stFrames { - pc := uintptr(stFrames[i]) - fn := runtime.FuncForPC(pc) - file, line := fn.FileLine(pc) - frame := raven.NewStacktraceFrame(pc, fn.Name(), file, line, stConfig.Context, stConfig.InAppPrefixes) + for _, stFrame := range stFrames { + frame := raven.NewStacktraceFrame(stFrame.PC, stFrame.Func.Name(), stFrame.File, stFrame.Line, + stConfig.Context, stConfig.InAppPrefixes) if frame != nil { frames = append(frames, frame) } From 82d1ae2c13159fbc1dde8fb3042ab4b6e85e79a4 Mon Sep 17 00:00:00 2001 From: Mohamad mehdi Kharatizadeh Date: Sat, 5 Jan 2019 21:57:20 +0330 Subject: [PATCH 2/2] Add one more skip level due to breaking change in github.com/sirupsen/logrus Apparently due to this [merge request](https://github.com/sirupsen/logrus/pull/863) another level to stacktrace was introduced. So if we intend to skip it by default we have to increase default number of skips in our configuration. --- sentry.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sentry.go b/sentry.go index 4001dfe..59661f8 100644 --- a/sentry.go +++ b/sentry.go @@ -113,7 +113,7 @@ func NewWithClientSentryHook(client *raven.Client, levels []logrus.Level) (*Sent StacktraceConfiguration: StackTraceConfiguration{ Enable: false, Level: logrus.ErrorLevel, - Skip: 5, + Skip: 6, Context: 0, InAppPrefixes: nil, SendExceptionType: true,