Skip to content

Commit

Permalink
Ungroup Sentry Error
Browse files Browse the repository at this point in the history
that contains both of Environment Recovery Errors and Runner Recovery Errors.
  • Loading branch information
mpass99 committed Aug 17, 2024
1 parent cc9e20f commit 8bccbaf
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 6 additions & 2 deletions internal/environment/nomad_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion internal/nomad/api_querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions pkg/logging/sentry_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
Expand Down

0 comments on commit 8bccbaf

Please sign in to comment.