@@ -3,6 +3,7 @@ package observance
3
3
import (
4
4
"io"
5
5
"os"
6
+ "strings"
6
7
"time"
7
8
8
9
"github.com/getsentry/sentry-go"
@@ -124,6 +125,9 @@ func NewLogrus(logLevel string, appName string, sentryURL string, version string
124
125
Dsn : sentryURL ,
125
126
AttachStacktrace : true ,
126
127
BeforeSend : func (event * sentry.Event , hint * sentry.EventHint ) * sentry.Event {
128
+ for i := range event .Exception {
129
+ event .Exception [i ].Stacktrace .Frames = filterVendorFrames (event .Exception [i ].Stacktrace .Frames )
130
+ }
127
131
// Remove the list of all packages of the service. It just spams Sentry.
128
132
event .Modules = make (map [string ]string )
129
133
return event
@@ -153,3 +157,18 @@ func NewLogrus(logLevel string, appName string, sentryURL string, version string
153
157
logger : logger ,
154
158
}, nil
155
159
}
160
+
161
+ // filterVendorFrames removes frames that belong to the vendor folder from the stack trace.
162
+ // That way, the Sentry GUI only shows the responsible line in the actual application code.
163
+ // Our Sentry instance runs an older version of Sentry that does not yet provide the option
164
+ // to enter stack trace filters in the settings.
165
+ func filterVendorFrames (frames []sentry.Frame ) []sentry.Frame {
166
+ filteredFrames := make ([]sentry.Frame , 0 , len (frames ))
167
+ for _ , frame := range frames {
168
+ if strings .Contains (frame .AbsPath , "vendor" ) {
169
+ continue
170
+ }
171
+ filteredFrames = append (filteredFrames , frame )
172
+ }
173
+ return filteredFrames
174
+ }
0 commit comments