Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

workflow: Add process name to error logs #57

Merged
merged 2 commits into from
Oct 15, 2024
Merged
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
4 changes: 2 additions & 2 deletions workflow.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ func runOnce(
// Exit cleanly if error returned is cancellation of context
return err
} else if err != nil {
logger.Error(ctx, fmt.Errorf("run error [role=%v]: %v", role, err))
logger.Error(ctx, fmt.Errorf("run error [role=%v], [process=%v]: %v", role, processName, err))
craeyefish marked this conversation as resolved.
Show resolved Hide resolved

// Return nil to try again
return nil
Expand All @@ -230,7 +230,7 @@ func runOnce(
// and if the parent context was cancelled then that will exit safely.
return nil
} else if err != nil {
logger.Error(ctx, fmt.Errorf("run error [role=%v]: %v", role, err))
logger.Error(ctx, fmt.Errorf("run error [role=%v], [process=%v]: %v", role, processName, err))
metrics.ProcessErrors.WithLabelValues(workflowName, processName).Inc()

timer := clock.NewTimer(errBackOff)
Expand Down
4 changes: 2 additions & 2 deletions workflow_internal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func Test_runOnce(t *testing.T) {
time.Minute,
)
require.Nil(t, err)
require.Contains(t, buf.String(), `"msg":"run error [role=role-1]: test error"`)
require.Contains(t, buf.String(), `"msg":"run error [role=role-1], [process=process-1]: test error"`)
})

t.Run("Cancelled parent context during process execution retries and exits with context.Canceled ", func(t *testing.T) {
Expand Down Expand Up @@ -149,7 +149,7 @@ func Test_runOnce(t *testing.T) {
)

require.Nil(t, err)
require.Contains(t, buf.String(), `"msg":"run error [role=role-1]: test error`)
require.Contains(t, buf.String(), `"msg":"run error [role=role-1], [process=process-1]: test error`)
})

t.Run("Updates process state", func(t *testing.T) {
Expand Down
Loading