Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop sending non-actionable errors to incident.io #2397

Merged
merged 2 commits into from
Jan 2, 2025
Merged
Show file tree
Hide file tree
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
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
}
12 changes: 12 additions & 0 deletions flow/shared/telemetry/incidentio_message_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"net/http"
"strings"
"time"

"go.temporal.io/sdk/activity"

"github.com/PeerDB-io/peer-flow/shared"
)

type IncidentIoAlert struct {
Expand Down Expand Up @@ -50,6 +53,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
Loading