diff --git a/.changeset/popular-items-admire.md b/.changeset/popular-items-admire.md new file mode 100644 index 00000000000..78bdcc6917a --- /dev/null +++ b/.changeset/popular-items-admire.md @@ -0,0 +1,5 @@ +--- +"chainlink": patch +--- + +#internal add metric for workflow execution start diff --git a/core/services/workflows/monitoring/monitoring.go b/core/services/workflows/monitoring/monitoring.go index fd3e57357ab..1ccd1c1bc1f 100644 --- a/core/services/workflows/monitoring/monitoring.go +++ b/core/services/workflows/monitoring/monitoring.go @@ -37,15 +37,17 @@ type EngineMetrics struct { engineHeartbeatCounter metric.Int64Counter engineHeartbeatGauge metric.Int64Gauge - workflowCompletedDurationSeconds metric.Int64Histogram - workflowEarlyExitDurationSeconds metric.Int64Histogram - workflowErrorDurationSeconds metric.Int64Histogram - workflowTimeoutDurationSeconds metric.Int64Histogram - workflowStepDurationSeconds metric.Int64Histogram + workflowCompletedDurationSeconds metric.Int64Histogram + workflowEarlyExitDurationSeconds metric.Int64Histogram + workflowErrorDurationSeconds metric.Int64Histogram + workflowTimeoutDurationSeconds metric.Int64Histogram + workflowStepDurationSeconds metric.Int64Histogram capabilityExecutionDurationSeconds metric.Int64Histogram - workflowMissingMeteringReport metric.Int64Counter - workflowMeteringMode metric.Int64Gauge + workflowMissingMeteringReport metric.Int64Counter + workflowMeteringMode metric.Int64Gauge + workflowExecutionFailedCounter metric.Int64Counter + workflowExecutionStartedCounter metric.Int64Counter workflowExecutionSucceededCounter metric.Int64Counter getSecretsDuration metric.Int64Histogram @@ -136,6 +138,11 @@ func InitMonitoringResources() (em *EngineMetrics, err error) { return nil, fmt.Errorf("failed to register workflow trigger event queue full counter: %w", err) } + em.workflowExecutionStartedCounter, err = beholder.GetMeter().Int64Counter("platform_engine_workflow_execution_started_count") + if err != nil { + return nil, fmt.Errorf("failed to register workflow execution started counter: %w", err) + } + em.workflowExecutionFailedCounter, err = beholder.GetMeter().Int64Counter("platform_engine_workflow_execution_failed_count") if err != nil { return nil, fmt.Errorf("failed to register workflow execution failed counter: %w", err) @@ -432,3 +439,8 @@ func (c WorkflowsMetricLabeler) IncrementWorkflowExecutionSucceededCounter(ctx c otelLabels := beholder.OtelAttributes(c.Labels).AsStringAttributes() c.em.workflowExecutionSucceededCounter.Add(ctx, 1, metric.WithAttributes(otelLabels...)) } + +func (c WorkflowsMetricLabeler) IncrementWorkflowExecutionStartedCounter(ctx context.Context) { + otelLabels := beholder.OtelAttributes(c.Labels).AsStringAttributes() + c.em.workflowExecutionStartedCounter.Add(ctx, 1, metric.WithAttributes(otelLabels...)) +} diff --git a/core/services/workflows/v2/engine.go b/core/services/workflows/v2/engine.go index 3aa4e4af1fd..59afd484eda 100644 --- a/core/services/workflows/v2/engine.go +++ b/core/services/workflows/v2/engine.go @@ -443,6 +443,7 @@ func (e *Engine) startExecution(ctx context.Context, wrappedTriggerEvent enqueue startTime := e.cfg.Clock.Now() executionLogger.Infow("Workflow execution starting ...") _ = events.EmitExecutionStartedEvent(ctx, e.loggerLabels, triggerEvent.ID, executionID) + e.metrics.With("workflowID", e.cfg.WorkflowID, "workflowName", e.cfg.WorkflowName.String()).IncrementWorkflowExecutionStartedCounter(ctx) var executionStatus string // store.StatusStarted var timeProvider TimeProvider = &types.LocalTimeProvider{}