We are using apex/log for structured logging and have implemented a handler for forwarding error level messages to Sentry.
Sentry isn’t doing a good job at disambiguating errors, instead grouping unrelated messages together. Has anyone got this working properly.
Here’s our handler:
// HandleLog implements log.sentryHandler.
func (h *sentryHandler) HandleLog(e *log.Entry) error {
switch e.Level {
case log.FatalLevel, log.ErrorLevel:
fields := map[string]string{}
for k, v := range e.Fields {
fields[k] = fmt.Sprintf("%+v", v)
}
ex, _ := os.Executable()
fields["bin"] = path.Base(ex)
if e.Level == log.FatalLevel {
raven.CaptureErrorAndWait(fmt.Errorf("%s", e.Message), fields)
} else if e.Level == log.ErrorLevel {
raven.CaptureError(fmt.Errorf("%s", e.Message), fields)
}
default:
// Nothing.
}
return h.other.HandleLog(e)
}