Skip to content

Commit 704de11

Browse files
committed
collect started metric
1 parent 769aea2 commit 704de11

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

internal/controller/controller.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,9 @@ func (s *Controller) handleActions(ctx context.Context, clusterActions []*castai
156156

157157
var err error
158158

159+
metrics.ActionStarted(action.GetType())
159160
startTime := time.Now()
161+
160162
handleErr := s.handleAction(ctx, action)
161163
if errors.Is(handleErr, context.Canceled) {
162164
// Action should be handled again on context canceled errors.

internal/metrics/custom_metrics.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/prometheus/client_golang/prometheus"
88
)
99

10+
// actionStartedCounter tracks actions started by the cluster controller.
1011
var actionStartedCounter = prometheus.NewCounterVec(
1112
prometheus.CounterOpts{
1213
Name: "action_started_total",
@@ -24,6 +25,11 @@ var actionExecutedCounter = prometheus.NewCounterVec(
2425
[]string{"success", "type"},
2526
)
2627

28+
// actionExecutedDuration tracks the duration of actions executed by the cluster controller.
29+
// Summary is used instead of histogram to use less series.
30+
// We cannot run aggregations on Prometheus side with Summaries,
31+
// but there is only a single active cluster controller pod,
32+
// so this might not be a problem.
2733
var actionExecutedDuration = prometheus.NewSummaryVec(
2834
prometheus.SummaryOpts{
2935
Name: "action_executed_duration_seconds",

internal/metrics/register.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import (
66

77
func RegisterCustomMetrics() {
88
registry.MustRegister(
9-
actionCounter,
9+
actionStartedCounter,
10+
actionExecutedCounter,
1011
actionExecutedDuration,
11-
actionExecutedDurationSummary,
1212
)
1313
}

0 commit comments

Comments
 (0)