From 8bccbaf4365a072c4b6923bc2fe57f3715db3d81 Mon Sep 17 00:00:00 2001 From: Maximilian Pass <22845248+mpass99@users.noreply.github.com> Date: Sat, 17 Aug 2024 12:58:17 +0200 Subject: [PATCH] Ungroup Sentry Error that contains both of Environment Recovery Errors and Runner Recovery Errors. --- internal/environment/nomad_manager.go | 8 ++++++-- internal/nomad/api_querier.go | 2 +- pkg/logging/sentry_hook.go | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/internal/environment/nomad_manager.go b/internal/environment/nomad_manager.go index df015885..9270394c 100644 --- a/internal/environment/nomad_manager.go +++ b/internal/environment/nomad_manager.go @@ -181,13 +181,17 @@ func (m *NomadEnvironmentManager) KeepEnvironmentsSynced(ctx context.Context, sy err := util.RetryConstantAttemptsWithContext(ctx, math.MaxInt, func() error { // Load Environments if err := m.load(ctx); err != nil { - log.WithContext(ctx).WithError(err).Warn("Loading Environments failed! Retrying...") + log.WithContext(ctx).WithError(err). + WithField(logging.SentryFingerprintFieldKey, []string{"{{ default }}", "environments"}). + Warn("Loading Environments failed! Retrying...") return err } // Load Runners and keep them synchronized. if err := synchronizeRunners(ctx); err != nil && ctx.Err() == nil { - log.WithContext(ctx).WithError(err).Warn("Loading and synchronizing Runners failed! Retrying...") + log.WithContext(ctx).WithError(err). + WithField(logging.SentryFingerprintFieldKey, []string{"{{ default }}", "runners"}). + Warn("Loading and synchronizing Runners failed! Retrying...") return err } diff --git a/internal/nomad/api_querier.go b/internal/nomad/api_querier.go index 3cc5ad30..8f35d71a 100644 --- a/internal/nomad/api_querier.go +++ b/internal/nomad/api_querier.go @@ -142,7 +142,7 @@ func (nc *nomadAPIClient) Execute(ctx context.Context, runnerID string, cmd stri // events of this error are caused by fsouza/go-dockerclient#1076. Because this error happens at the very end, // it does not affect the functionality. Therefore, we don't propagate the error. log.WithContext(span.Context()).WithError(err). - WithField(logging.SentryFingerprintFieldKey, "nomad-unexpected-eof").Warn("Unexpected EOF for Execute") + WithField(logging.SentryFingerprintFieldKey, []string{"nomad-unexpected-eof"}).Warn("Unexpected EOF for Execute") return 0, nil case strings.Contains(err.Error(), "Unknown allocation"): return 1, ErrNomadUnknownAllocation diff --git a/pkg/logging/sentry_hook.go b/pkg/logging/sentry_hook.go index b03b1c0c..65cd3686 100644 --- a/pkg/logging/sentry_hook.go +++ b/pkg/logging/sentry_hook.go @@ -54,8 +54,8 @@ func handleLogEntry(entry *logrus.Entry, hub *sentry.Hub, scope *sentry.Scope) ( if environmentID, ok := entry.Data[dto.KeyEnvironmentID].(string); ok { scope.SetTag(dto.KeyEnvironmentID, environmentID) } - if fingerprint, ok := entry.Data[SentryFingerprintFieldKey].(string); ok { - scope.SetFingerprint([]string{fingerprint}) + if fingerprint, ok := entry.Data[SentryFingerprintFieldKey].([]string); ok { + scope.SetFingerprint(fingerprint) } event := client.EventFromMessage(entry.Message, sentry.Level(entry.Level.String()))