Called before workflow execution to wrap the workflow in custom logic
The workflow context map containing workflow metadata and state
Function to call the next interceptor or the workflow itself
The result of the workflow execution
// Metrics interceptor implementation
{
async execute(ctx, next) {
const workflowName = ctx.get('workflowName');
const metrics = getMetricsClient();
metrics.increment(`workflow.start.${workflowName}`);
const timer = metrics.startTimer();
try {
const result = await next();
metrics.increment(`workflow.success.${workflowName}`);
return result;
} catch (err) {
metrics.increment(`workflow.error.${workflowName}`);
throw err;
} finally {
timer.end();
}
}
}
Workflow interceptor that can wrap workflow execution in an onion-like pattern. Each interceptor wraps the next one, with the actual workflow execution at the center.
Interceptors are executed in the order they are registered. Each interceptor can:
Example