Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions observance/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package observance
import (
"io"
"os"
"strings"
"time"

"github.com/getsentry/sentry-go"
Expand Down Expand Up @@ -124,6 +125,9 @@ func NewLogrus(logLevel string, appName string, sentryURL string, version string
Dsn: sentryURL,
AttachStacktrace: true,
BeforeSend: func(event *sentry.Event, hint *sentry.EventHint) *sentry.Event {
for i := range event.Exception {
event.Exception[i].Stacktrace.Frames = filterVendorFrames(event.Exception[i].Stacktrace.Frames)
}
// Remove the list of all packages of the service. It just spams Sentry.
event.Modules = make(map[string]string)
return event
Expand Down Expand Up @@ -153,3 +157,18 @@ func NewLogrus(logLevel string, appName string, sentryURL string, version string
logger: logger,
}, nil
}

// filterVendorFrames removes frames that belong to the vendor folder from the stack trace.
// That way, the Sentry GUI only shows the responsible line in the actual application code.
// Our Sentry instance runs an older version of Sentry that does not yet provide the option
// to enter stack trace filters in the settings.
func filterVendorFrames(frames []sentry.Frame) []sentry.Frame {
filteredFrames := make([]sentry.Frame, 0, len(frames))
for _, frame := range frames {
if strings.Contains(frame.AbsPath, "vendor") {
continue
}
filteredFrames = append(filteredFrames, frame)
}
return filteredFrames
}