Skip to content

Commit

Permalink
Adds heartbeat metric
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzaldysanchez committed Oct 31, 2024
1 parent 020ec5b commit 48274ab
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/services/workflows/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
11 changes: 11 additions & 0 deletions core/services/workflows/monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 48274ab

Please sign in to comment.