From 48274ab696d852696c5c28606f5605968b2fbc20 Mon Sep 17 00:00:00 2001 From: vyzaldysanchez Date: Thu, 31 Oct 2024 12:28:42 -0400 Subject: [PATCH] Adds heartbeat metric --- core/services/workflows/engine.go | 1 + core/services/workflows/monitoring.go | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/core/services/workflows/engine.go b/core/services/workflows/engine.go index 8768d681375..7550d06cf95 100644 --- a/core/services/workflows/engine.go +++ b/core/services/workflows/engine.go @@ -1049,6 +1049,7 @@ func (e *Engine) heartbeat(ctx context.Context) { e.logger.Info("shutting down heartbeat") return case <-ticker.C: + e.metrics.incrementEngineHeartbeatCounter(ctx) logCustMsg(e.cma, "engine heartbeat at: "+e.clock.Now().Format(time.RFC3339), e.logger) } } diff --git a/core/services/workflows/monitoring.go b/core/services/workflows/monitoring.go index 8f5601554ed..bd448afd9e5 100644 --- a/core/services/workflows/monitoring.go +++ b/core/services/workflows/monitoring.go @@ -17,6 +17,7 @@ var workflowsRunningGauge metric.Int64Gauge var capabilityInvocationCounter metric.Int64Counter var workflowExecutionLatencyGauge metric.Int64Gauge // ms var workflowStepErrorCounter metric.Int64Counter +var engineHeartbeatCounter metric.Int64UpDownCounter func initMonitoringResources() (err error) { registerTriggerFailureCounter, err = beholder.GetMeter().Int64Counter("RegisterTriggerFailure") @@ -44,6 +45,11 @@ func initMonitoringResources() (err error) { return fmt.Errorf("failed to register workflow step error counter: %w", err) } + engineHeartbeatCounter, err = beholder.GetMeter().Int64UpDownCounter("EngineHeartbeat") + if err != nil { + return fmt.Errorf("failed to register engine heartbeat counter: %w", err) + } + return nil } @@ -82,6 +88,11 @@ func (c workflowsMetricLabeler) updateTotalWorkflowsGauge(ctx context.Context, v workflowsRunningGauge.Record(ctx, val, metric.WithAttributes(otelLabels...)) } +func (c workflowsMetricLabeler) incrementEngineHeartbeatCounter(ctx context.Context) { + otelLabels := localMonitoring.KvMapToOtelAttributes(c.Labels) + engineHeartbeatCounter.Add(ctx, 1, metric.WithAttributes(otelLabels...)) +} + // Observability keys const ( cIDKey = "capabilityID"