Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
12 changes: 11 additions & 1 deletion flow/alerting/alerting.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ import (
"io"
"log/slog"
"net"
"reflect"
"slices"
"strings"
"time"

"github.com/ClickHouse/clickhouse-go/v2"
"github.com/davecgh/go-spew/spew"
"github.com/go-mysql-org/go-mysql/mysql"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
Expand Down Expand Up @@ -445,6 +447,11 @@ const (
flowErrorTypeError flowErrorType = "error"
)

var errSpew = spew.ConfigState{
Indent: " ",
DisableMethods: true, // Don't call Error() method, show the actual fields
}

// logFlowErrorInternal pushes the error to the errors table and emits a metric as well as a telemetry message
func (a *Alerter) logFlowErrorInternal(
ctx context.Context,
Expand All @@ -456,7 +463,10 @@ func (a *Alerter) logFlowErrorInternal(
logger := internal.LoggerFromCtx(ctx)
inErrWithStack := fmt.Sprintf("%+v", inErr)
errError := inErr.Error()
loggerFunc(errError, slog.String("stack", inErrWithStack))
loggerFunc(errError,
slog.String("stack", inErrWithStack),
slog.String("type", reflect.TypeOf(inErr).String()),
slog.String("spew", errSpew.Sdump(inErr)))
Comment on lines 465 to 467
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good idea 👍

if _, err := a.CatalogPool.Exec(
ctx, "INSERT INTO peerdb_stats.flow_errors(flow_name,error_message,error_type) VALUES($1,$2,$3)",
flowName, inErrWithStack, errorType.String(),
Expand Down
13 changes: 13 additions & 0 deletions flow/alerting/classifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,19 @@ func GetErrorClass(ctx context.Context, err error) (ErrorClass, ErrorInfo) {
}
}

var mongoDriverError driver.Error
if errors.As(err, &mongoDriverError) {
mongoErrorInfo := ErrorInfo{
Source: ErrorSourceMongoDB,
Code: strconv.Itoa(int(mongoDriverError.Code)),
}

// This should recover, but we notify if exceed default threshold
if mongoDriverError.HasErrorLabel(driver.TransientTransactionError) {
return ErrorNotifyConnectivity, mongoErrorInfo
}
}

var mongoMarshalErr mongo.MarshalError
if errors.As(err, &mongoMarshalErr) {
return ErrorOther, ErrorInfo{
Expand Down
Loading