Skip to content

Commit 845eeb3

Browse files
[SENTRY CLEANUP] Do not send some errors to sentry (#215)
Some errors are simply not actionable and should not be sent to sentry. Logging is appriopriate in all these cases.
1 parent b69e565 commit 845eeb3

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

telemetry/errors.go

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
package telemetry
22

33
import (
4+
"context"
5+
"errors"
6+
"strings"
7+
48
"github.com/getsentry/sentry-go"
59
"go.opentelemetry.io/otel"
610
"go.uber.org/zap"
@@ -16,5 +20,30 @@ func (eh ErrorHandler) Handle(err error) {
1620
// +1 for this wrapper, +3 for opentelemetry-go's internal error handling code
1721
log := logger.WithOptions(zap.AddCallerSkip(4))
1822
log.Warn("opentelemetry error", zap.Error(err))
19-
sentry.CaptureException(err)
23+
switch {
24+
case logOnlyError(err):
25+
// do not capture these errors in sentry
26+
default:
27+
sentry.CaptureException(err)
28+
}
29+
}
30+
31+
func logOnlyError(err error) bool {
32+
switch {
33+
case errors.Is(err, context.DeadlineExceeded):
34+
return true
35+
// Server said go away
36+
case strings.Contains(err.Error(), "GO AWAY"):
37+
return true
38+
// Connection reset by peer, this isn't something we can do much about
39+
case strings.Contains(err.Error(), "connection reset by peer"):
40+
return true
41+
// processor export timeout, this is not actionable by us, happens in `POST`
42+
case strings.Contains(err.Error(), "processor export timeout"):
43+
return true
44+
// cannot rewind body, happens when retrying a request with a non-rewindable body
45+
case strings.Contains(err.Error(), "cannot rewind body"):
46+
return true
47+
}
48+
return false
2049
}

0 commit comments

Comments
 (0)