From d23b4bec36026c4ce72807df191b44689a9e8e1c Mon Sep 17 00:00:00 2001 From: ElectroNafta <163560174+ElectroNafta@users.noreply.github.com> Date: Mon, 23 Sep 2024 17:15:49 +0200 Subject: [PATCH] feat(BRIDGE-204): removed unneccessary noisy sentry events (#412) Removed redundant sentry events: - Failed to parse IMAP command - Failed to create mailbox - Failed to delete mailbox - Failed to copy messages - Failed to move messages from mailbox - Failed to remove deleted messages - Failed to commit database transaction - Failed to insert message into recovery mailbox (not enough space) --- internal/backend/user.go | 4 ---- internal/db_impl/sqlite3/client.go | 9 --------- internal/session/command.go | 6 ------ internal/session/handle_copy.go | 8 -------- internal/session/handle_create.go | 8 -------- internal/session/handle_delete.go | 8 -------- internal/session/handle_move.go | 8 -------- internal/state/mailbox.go | 2 -- 8 files changed, 53 deletions(-) diff --git a/internal/backend/user.go b/internal/backend/user.go index cab57c14..3412f675 100644 --- a/internal/backend/user.go +++ b/internal/backend/user.go @@ -149,10 +149,6 @@ func newUser( if err := user.deleteAllMessagesMarkedDeleted(ctx); err != nil { log.WithError(err).Error("Failed to remove deleted messages") - reporter.MessageWithContext(ctx, - "Failed to remove deleted messages", - reporter.Context{"error": err}, - ) } if err := user.cleanupStaleStoreData(ctx); err != nil { diff --git a/internal/db_impl/sqlite3/client.go b/internal/db_impl/sqlite3/client.go index 880e4a31..7e82f36d 100644 --- a/internal/db_impl/sqlite3/client.go +++ b/internal/db_impl/sqlite3/client.go @@ -14,8 +14,6 @@ import ( "github.com/ProtonMail/gluon/db" "github.com/ProtonMail/gluon/imap" "github.com/ProtonMail/gluon/internal/db_impl/sqlite3/utils" - gluon_utils "github.com/ProtonMail/gluon/internal/utils" - "github.com/ProtonMail/gluon/reporter" "github.com/google/uuid" _ "github.com/mattn/go-sqlite3" "github.com/sirupsen/logrus" @@ -193,13 +191,6 @@ func (c *Client) wrapTx(ctx context.Context, op func(context.Context, *sql.Tx, * } if err := tx.Commit(); err != nil { - if !errors.Is(err, context.Canceled) { - reporter.MessageWithContext(ctx, - "Failed to commit database transaction", - reporter.Context{"error": err, "type": gluon_utils.ErrCause(err)}, - ) - } - if c.debug { entry.Debugf("Failed to commit Transaction") } diff --git a/internal/session/command.go b/internal/session/command.go index a639bb97..18025dd4 100644 --- a/internal/session/command.go +++ b/internal/session/command.go @@ -9,7 +9,6 @@ import ( "github.com/ProtonMail/gluon/imap/command" "github.com/ProtonMail/gluon/internal/response" "github.com/ProtonMail/gluon/logging" - "github.com/ProtonMail/gluon/reporter" "github.com/ProtonMail/gluon/rfcparser" ) @@ -63,11 +62,6 @@ func (s *Session) startCommandReader(ctx context.Context) <-chan commandResult { } s.log.WithError(err).WithField("type", parser.LastParsedCommand()).Error("Failed to parse IMAP command") - - reporter.MessageWithContext(ctx, - "Failed to parse IMAP command", - reporter.Context{"error": err, "cmd": parser.LastParsedCommand()}, - ) } else { s.log.Debug(cmd.SanitizedString()) } diff --git a/internal/session/handle_copy.go b/internal/session/handle_copy.go index fb0d9630..4169e1f4 100644 --- a/internal/session/handle_copy.go +++ b/internal/session/handle_copy.go @@ -9,7 +9,6 @@ import ( "github.com/ProtonMail/gluon/internal/response" "github.com/ProtonMail/gluon/internal/state" "github.com/ProtonMail/gluon/profiling" - "github.com/ProtonMail/gluon/reporter" ) func (s *Session) handleCopy(ctx context.Context, tag string, cmd *command.Copy, mailbox *state.Mailbox, ch chan response.Response) (response.Response, error) { @@ -38,13 +37,6 @@ func (s *Session) handleCopy(ctx context.Context, tag string, cmd *command.Copy, } else if errors.Is(err, state.ErrNoSuchMailbox) { return response.No(tag).WithError(err).WithItems(response.ItemTryCreate()), nil } else if err != nil { - if shouldReportIMAPCommandError(err) { - reporter.MessageWithContext(ctx, - "Failed to copy messages", - reporter.Context{"error": err, "mailbox_to": nameUTF8, "mailbox_from": mailbox.Name()}, - ) - } - return nil, err } diff --git a/internal/session/handle_create.go b/internal/session/handle_create.go index c4d60eb8..b2a51013 100644 --- a/internal/session/handle_create.go +++ b/internal/session/handle_create.go @@ -8,7 +8,6 @@ import ( "github.com/ProtonMail/gluon/imap/command" "github.com/ProtonMail/gluon/internal/response" "github.com/ProtonMail/gluon/profiling" - "github.com/ProtonMail/gluon/reporter" ) func (s *Session) handleCreate(ctx context.Context, tag string, cmd *command.Create, ch chan response.Response) error { @@ -25,13 +24,6 @@ func (s *Session) handleCreate(ctx context.Context, tag string, cmd *command.Cre } if err := s.state.Create(ctx, nameUTF8); err != nil { - if shouldReportIMAPCommandError(err) { - reporter.MessageWithContext(ctx, - "Failed to create mailbox", - reporter.Context{"error": err, "mailbox": nameUTF8}, - ) - } - return err } diff --git a/internal/session/handle_delete.go b/internal/session/handle_delete.go index 97bb7fb5..09f04ec5 100644 --- a/internal/session/handle_delete.go +++ b/internal/session/handle_delete.go @@ -8,7 +8,6 @@ import ( "github.com/ProtonMail/gluon/imap/command" "github.com/ProtonMail/gluon/internal/response" "github.com/ProtonMail/gluon/profiling" - "github.com/ProtonMail/gluon/reporter" ) func (s *Session) handleDelete(ctx context.Context, tag string, cmd *command.Delete, ch chan response.Response) error { @@ -26,13 +25,6 @@ func (s *Session) handleDelete(ctx context.Context, tag string, cmd *command.Del selectedDeleted, err := s.state.Delete(ctx, nameUTF8) if err != nil { - if shouldReportIMAPCommandError(err) { - reporter.MessageWithContext(ctx, - "Failed to delete mailbox", - reporter.Context{"error": err, "mailbox": nameUTF8}, - ) - } - return err } diff --git a/internal/session/handle_move.go b/internal/session/handle_move.go index 8406a4d7..ec047e82 100644 --- a/internal/session/handle_move.go +++ b/internal/session/handle_move.go @@ -9,7 +9,6 @@ import ( "github.com/ProtonMail/gluon/internal/response" "github.com/ProtonMail/gluon/internal/state" "github.com/ProtonMail/gluon/profiling" - "github.com/ProtonMail/gluon/reporter" ) func (s *Session) handleMove(ctx context.Context, tag string, cmd *command.Move, mailbox *state.Mailbox, ch chan response.Response) (response.Response, error) { @@ -36,13 +35,6 @@ func (s *Session) handleMove(ctx context.Context, tag string, cmd *command.Move, } else if errors.Is(err, state.ErrNoSuchMailbox) { return response.No(tag).WithError(err).WithItems(response.ItemTryCreate()), nil } else if err != nil { - if shouldReportIMAPCommandError(err) { - reporter.MessageWithContext(ctx, - "Failed to move messages from mailbox", - reporter.Context{"error": err, "mailbox_to": nameUTF8, "mailbox_from": mailbox.Name()}, - ) - } - return nil, err } diff --git a/internal/state/mailbox.go b/internal/state/mailbox.go index 0b27ef8b..a75b2719 100644 --- a/internal/state/mailbox.go +++ b/internal/state/mailbox.go @@ -13,7 +13,6 @@ import ( "github.com/ProtonMail/gluon/imap/command" "github.com/ProtonMail/gluon/internal/ids" "github.com/ProtonMail/gluon/internal/response" - "github.com/ProtonMail/gluon/reporter" "github.com/ProtonMail/gluon/rfc822" "github.com/bradenaw/juniper/xslices" "github.com/sirupsen/logrus" @@ -251,7 +250,6 @@ func (m *Mailbox) Append(ctx context.Context, literal []byte, flags imap.FlagSet }) if recoverErr != nil && !knownMessage { m.log.WithError(recoverErr).Error("Failed to insert message into recovery mailbox") - reporter.ExceptionWithContext(ctx, "Failed to insert message into recovery mailbox", reporter.Context{"error": recoverErr}) } if knownMessage {