Skip to content

Commit e6e47f9

Browse files
committed
Extract const for metrics namespace
1 parent 087861c commit e6e47f9

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

pkg/sharding/metrics/metrics.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,37 +22,43 @@ import (
2222
"sigs.k8s.io/controller-runtime/pkg/metrics"
2323
)
2424

25+
const Namespace = "controller_sharding"
26+
2527
var (
2628
// AssignmentsTotal is a prometheus counter metric which holds the total number of shard assignments by the sharder
2729
// webhook per ControllerRing and GroupResource.
2830
// It has a label which refers to the ControllerRing and two labels which refer to the object's GroupResource.
2931
AssignmentsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
30-
Name: "controller_sharding_assignments_total",
31-
Help: "Total number of shard assignments by the sharder webhook per ControllerRing and GroupResource",
32+
Namespace: Namespace,
33+
Name: "assignments_total",
34+
Help: "Total number of shard assignments by the sharder webhook per ControllerRing and GroupResource",
3235
}, []string{"controllerring", "group", "resource"})
3336

3437
// MovementsTotal is a prometheus counter metric which holds the total number of shard movements triggered by the
3538
// sharder controller per ControllerRing and GroupResource.
3639
// It has a label which refers to the ControllerRing and two labels which refer to the object's GroupResource.
3740
MovementsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
38-
Name: "controller_sharding_movements_total",
39-
Help: "Total number of shard movements triggered by the sharder controller per ControllerRing and GroupResource",
41+
Namespace: Namespace,
42+
Name: "movements_total",
43+
Help: "Total number of shard movements triggered by the sharder controller per ControllerRing and GroupResource",
4044
}, []string{"controllerring", "group", "resource"})
4145

4246
// DrainsTotal is a prometheus counter metric which holds the total number of shard drains triggered by the sharder
4347
// controller per ControllerRing and GroupResource.
4448
// It has a label which refers to the ControllerRing and two labels which refer to the object's GroupResource.
4549
DrainsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
46-
Name: "controller_sharding_drains_total",
47-
Help: "Total number of shard drains triggered by the sharder controller per ControllerRing and GroupResource",
50+
Namespace: Namespace,
51+
Name: "drains_total",
52+
Help: "Total number of shard drains triggered by the sharder controller per ControllerRing and GroupResource",
4853
}, []string{"controllerring", "group", "resource"})
4954

5055
// RingCalculationsTotal is a prometheus counter metric which holds the total
5156
// number of hash ring calculations per ControllerRing.
5257
// It has a label which refers to the ControllerRing.
5358
RingCalculationsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
54-
Name: "controller_sharding_ring_calculations_total",
55-
Help: "Total number of hash ring calculations per ControllerRing",
59+
Namespace: Namespace,
60+
Name: "ring_calculations_total",
61+
Help: "Total number of hash ring calculations per ControllerRing",
5662
}, []string{"controllerring"})
5763
)
5864

0 commit comments

Comments
 (0)