Skip to content

Commit

Permalink
workflow: Add process name to error logs (#57)
Browse files Browse the repository at this point in the history
* workflow: Add process name to error logs

* update fmt to expect string
  • Loading branch information
craeyefish authored Oct 15, 2024
1 parent c54ce1d commit 4e70b2a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
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=%s], [process=%s]: %v", role, processName, err))

// 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=%s], [process=%s]: %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

0 comments on commit 4e70b2a

Please sign in to comment.