Skip to content

Commit

Permalink
Stop sending non-actionable errors to incident.io
Browse files Browse the repository at this point in the history
  • Loading branch information
iskakaushik committed Dec 27, 2024
1 parent 1305dec commit 47a1f9d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 4 deletions.
8 changes: 4 additions & 4 deletions flow/alerting/alerting.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,21 +440,21 @@ func (a *Alerter) LogFlowError(ctx context.Context, flowName string, err error)
}
var tags []string
if errors.Is(err, context.Canceled) {
tags = append(tags, "err:Canceled")
tags = append(tags, string(shared.ErrTypeCanceled))
}
if errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {
tags = append(tags, "err:EOF")
tags = append(tags, string(shared.ErrTypeEOF))
}
if errors.Is(err, net.ErrClosed) {
tags = append(tags, "err:Closed")
tags = append(tags, string(shared.ErrTypeClosed))
}
var pgErr *pgconn.PgError
if errors.As(err, &pgErr) {
tags = append(tags, "pgcode:"+pgErr.Code)
}
var netErr *net.OpError
if errors.As(err, &netErr) {
tags = append(tags, "err:Net")
tags = append(tags, string(shared.ErrTypeNet))
}
a.sendTelemetryMessage(ctx, logger, flowName, errorWithStack, telemetry.ERROR, tags...)
}
Expand Down
24 changes: 24 additions & 0 deletions flow/shared/err_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package shared

type ErrType string

const (
ErrTypeCanceled ErrType = "err:Canceled"
ErrTypeClosed ErrType = "err:Closed"
ErrTypeNet ErrType = "err:Net"
ErrTypeEOF ErrType = "err:EOF"
)

func SkipSendingToIncidentIo(errTags []string) bool {
skipTags := map[string]struct{}{
string(ErrTypeCanceled): {},
string(ErrTypeClosed): {},
string(ErrTypeNet): {},
}
for _, tag := range errTags {
if _, ok := skipTags[tag]; ok {
return true
}
}
return false
}
11 changes: 11 additions & 0 deletions flow/shared/telemetry/incidentio_message_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"net/http"
"strings"
"time"

"github.com/PeerDB-io/peer-flow/shared"
"go.temporal.io/sdk/activity"
)

Expand Down Expand Up @@ -50,6 +52,15 @@ func (i *IncidentIoMessageSender) SendMessage(
activityInfo = activity.GetInfo(ctx)
}

if shared.SkipSendingToIncidentIo(attributes.Tags) {
logger := shared.LoggerFromCtx(ctx)
logger.Info("skipping incident.io alert",
slog.Any("attributes", attributes),
slog.String("subject", subject),
slog.String("body", body))
return "", nil
}

deduplicationString := strings.Join([]string{
"deployID", attributes.DeploymentUID,
"subject", subject,
Expand Down

0 comments on commit 47a1f9d

Please sign in to comment.