-
Notifications
You must be signed in to change notification settings - Fork 339
/
metrics.go
64 lines (57 loc) · 1.76 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package common
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"sigs.k8s.io/controller-runtime/pkg/metrics"
)
// Define all the prometheus counters for all clusters
var (
clustersCreatedCount = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ray_operator_clusters_created_total",
Help: "Counts number of clusters created",
},
[]string{"namespace"},
)
clustersDeletedCount = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ray_operator_clusters_deleted_total",
Help: "Counts number of clusters deleted",
},
[]string{"namespace"},
)
clustersSuccessfulCount = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ray_operator_clusters_successful_total",
Help: "Counts number of clusters successful",
},
[]string{"namespace"},
)
clustersFailedCount = promauto.NewCounterVec(
prometheus.CounterOpts{
Name: "ray_operator_clusters_failed_total",
Help: "Counts number of clusters failed",
},
[]string{"namespace"},
)
)
func init() {
// Register custom metrics with the global prometheus registry
metrics.Registry.MustRegister(clustersCreatedCount,
clustersDeletedCount,
clustersSuccessfulCount,
clustersFailedCount)
}
func CreatedClustersCounterInc(namespace string) {
clustersCreatedCount.WithLabelValues(namespace).Inc()
}
// TODO: We don't handle the delete events in new reconciler mode, how to emit deletion metrics?
func DeletedClustersCounterInc(namespace string) {
clustersDeletedCount.WithLabelValues(namespace).Inc()
}
func SuccessfulClustersCounterInc(namespace string) {
clustersSuccessfulCount.WithLabelValues(namespace).Inc()
}
func FailedClustersCounterInc(namespace string) {
clustersFailedCount.WithLabelValues(namespace).Inc()
}