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

adding custom message w/ workflow execution ID when duration exceeds 15 minutes #15241

Merged
merged 3 commits into from
Nov 14, 2024
Merged
Changes from all commits
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
18 changes: 15 additions & 3 deletions core/services/workflows/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import (
"github.com/smartcontractkit/chainlink/v2/core/services/workflows/store"
)

const fifteenMinutesMs = 15 * 60 * 1000

type stepRequest struct {
stepRef string
state store.WorkflowExecution
Expand Down Expand Up @@ -622,7 +624,7 @@ func (e *Engine) handleStepUpdate(ctx context.Context, stepUpdate store.Workflow
// the async nature of the workflow engine would provide no guarantees.
}
logCustMsg(ctx, cma, "execution status: "+status, l)
return e.finishExecution(ctx, state.ExecutionID, status)
return e.finishExecution(ctx, cma, state.ExecutionID, status)
}

// Finally, since the workflow hasn't timed out or completed, let's
Expand Down Expand Up @@ -669,9 +671,12 @@ func (e *Engine) queueIfReady(state store.WorkflowExecution, step *step) {
}
}

func (e *Engine) finishExecution(ctx context.Context, executionID string, status string) error {
e.logger.With(platform.KeyWorkflowExecutionID, executionID, "status", status).Info("finishing execution")
func (e *Engine) finishExecution(ctx context.Context, cma custmsg.MessageEmitter, executionID string, status string) error {
l := e.logger.With(platform.KeyWorkflowExecutionID, executionID, "status", status)
metrics := e.metrics.with("status", status)

l.Info("finishing execution")

err := e.executionStates.UpdateStatus(ctx, executionID, status)
if err != nil {
return err
Expand All @@ -687,6 +692,13 @@ func (e *Engine) finishExecution(ctx context.Context, executionID string, status
e.stepUpdatesChMap.remove(executionID)
metrics.updateTotalWorkflowsGauge(ctx, e.stepUpdatesChMap.len())
metrics.updateWorkflowExecutionLatencyGauge(ctx, executionDuration)

if executionDuration > fifteenMinutesMs {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style nit: you could have just written 15 * time.Minutes :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i take another pass I will update, thank you!

logCustMsg(ctx, cma, fmt.Sprintf("execution duration exceeded 15 minutes: %d", executionDuration), l)
l.Warnf("execution duration exceeded 15 minutes: %d", executionDuration)
}
logCustMsg(ctx, cma, fmt.Sprintf("execution duration: %d", executionDuration), l)
l.Infof("execution duration: %d", executionDuration)
e.onExecutionFinished(executionID)
return nil
}
Expand Down
Loading