Skip to content

Commit

Permalink
feat(BRIDGE-228): updated gluon observability metrics (#415)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroNafta authored Oct 18, 2024
1 parent ddf4a45 commit 31e040c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
13 changes: 4 additions & 9 deletions internal/session/handle_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import (
"github.com/ProtonMail/gluon/internal/contexts"
"github.com/ProtonMail/gluon/internal/response"
"github.com/ProtonMail/gluon/internal/state"
"github.com/ProtonMail/gluon/observability"
"github.com/ProtonMail/gluon/observability/metrics"
"github.com/ProtonMail/gluon/profiling"
"github.com/ProtonMail/gluon/reporter"
)

func (s *Session) handleStore(ctx context.Context, tag string, cmd *command.Store, mailbox *state.Mailbox, ch chan response.Response) (response.Response, error) {
Expand Down Expand Up @@ -37,14 +38,8 @@ func (s *Session) handleStore(ctx context.Context, tag string, cmd *command.Stor
if err := mailbox.Store(ctx, cmd.SeqSet, cmd.Action, flags); errors.Is(err, state.ErrNoSuchMessage) {
return response.Bad(tag).WithError(err), nil
} else if err != nil {
if shouldReportIMAPCommandError(err) {
// A result of either a failed request, or the message does not exist on the remote.
// We've agreed to keep this in sentry.
reporter.MessageWithContext(ctx,
"Failed to store flags on messages",
reporter.Context{"error": err, "mailbox": mailbox.Name(), "action": cmd.Action.String()},
)
}
// A result of either a failed request (API unreachable), or the message does not exist on remote.
observability.AddMessageRelatedMetric(ctx, metrics.GenerateFailedToStoreFlagsOnMessages())

return nil, err
}
Expand Down
4 changes: 4 additions & 0 deletions observability/metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,7 @@ func GenerateAppendToDraftsMustNotReturnExistingRemoteID() map[string]interface{
func GenerateDatabaseMigrationFailed() map[string]interface{} {
return generateGluonErrorMetric("databaseMigrationFailed")
}

func GenerateFailedToStoreFlagsOnMessages() map[string]interface{} {
return generateGluonErrorMetric("failedToStoreFlagsOnMessages")
}

0 comments on commit 31e040c

Please sign in to comment.