@@ -32,21 +32,21 @@ import (
32
32
var (
33
33
// client metrics
34
34
35
- requestLatency = prometheus . NewHistogramVec (
36
- prometheus. HistogramOpts {
37
- Name : "rest_client_request_latency_seconds" ,
38
- Help : "Request latency in seconds. Broken down by verb and URL. " ,
39
- Buckets : prometheus . ExponentialBuckets ( 0.001 , 2 , 10 ) ,
40
- } ,
41
- []string {"verb" , "url" },
35
+ // RequestLatency is a prometheus metric which tracks the latency of requests
36
+ // broken down by verb and URL.
37
+ RequestLatency = prometheus . NewHistogramVec (prometheus. HistogramOpts {
38
+ Name : "rest_client_request_latency_seconds " ,
39
+ Help : "Request latency in seconds. Broken down by verb and URL." ,
40
+ Buckets : prometheus . ExponentialBuckets ( 0.001 , 2 , 10 ) ,
41
+ }, []string {"verb" , "url" },
42
42
)
43
43
44
- requestResult = prometheus . NewCounterVec (
45
- prometheus. CounterOpts {
46
- Name : "rest_client_requests_total" ,
47
- Help : "Number of HTTP requests, partitioned by status code, method, and host. " ,
48
- } ,
49
- []string {"code" , "method" , "host" },
44
+ // RequestResult is a prometheus metric that tracks the number of HTTP requests
45
+ // broken down by status code, method, and host.
46
+ RequestResult = prometheus . NewCounterVec (prometheus. CounterOpts {
47
+ Name : "rest_client_requests_total " ,
48
+ Help : "Number of HTTP requests, partitioned by status code, method, and host." ,
49
+ }, []string {"code" , "method" , "host" },
50
50
)
51
51
52
52
// reflector metrics
@@ -56,49 +56,65 @@ var (
56
56
57
57
reflectorSubsystem = "reflector"
58
58
59
- listsTotal = prometheus .NewCounterVec (prometheus.CounterOpts {
59
+ // ListsTotal is a prometheus metric tracking the total number of API lists done
60
+ // by the reflectors.
61
+ ListsTotal = prometheus .NewCounterVec (prometheus.CounterOpts {
60
62
Subsystem : reflectorSubsystem ,
61
63
Name : "lists_total" ,
62
64
Help : "Total number of API lists done by the reflectors" ,
63
65
}, []string {"name" })
64
66
65
- listsDuration = prometheus .NewSummaryVec (prometheus.SummaryOpts {
67
+ // ListsDuration is a prometheus metric tracking how long an API list takes to
68
+ // return and decode for the reflectors.
69
+ ListsDuration = prometheus .NewSummaryVec (prometheus.SummaryOpts {
66
70
Subsystem : reflectorSubsystem ,
67
71
Name : "list_duration_seconds" ,
68
72
Help : "How long an API list takes to return and decode for the reflectors" ,
69
73
}, []string {"name" })
70
74
71
- itemsPerList = prometheus .NewSummaryVec (prometheus.SummaryOpts {
75
+ // ItemsPerList is a prometheus metric tracking how many items an API list returns
76
+ // to the reflectors.
77
+ ItemsPerList = prometheus .NewSummaryVec (prometheus.SummaryOpts {
72
78
Subsystem : reflectorSubsystem ,
73
79
Name : "items_per_list" ,
74
80
Help : "How many items an API list returns to the reflectors" ,
75
81
}, []string {"name" })
76
82
77
- watchesTotal = prometheus .NewCounterVec (prometheus.CounterOpts {
83
+ // WatchesTotal is a prometheus metric tracking the total number of API watches
84
+ // done by the reflectors.
85
+ WatchesTotal = prometheus .NewCounterVec (prometheus.CounterOpts {
78
86
Subsystem : reflectorSubsystem ,
79
87
Name : "watches_total" ,
80
88
Help : "Total number of API watches done by the reflectors" ,
81
89
}, []string {"name" })
82
90
83
- shortWatchesTotal = prometheus .NewCounterVec (prometheus.CounterOpts {
91
+ // ShortWatchesTotal is a prometheus metric tracking the total number of short
92
+ // API watches done by the reflectors.
93
+ ShortWatchesTotal = prometheus .NewCounterVec (prometheus.CounterOpts {
84
94
Subsystem : reflectorSubsystem ,
85
95
Name : "short_watches_total" ,
86
96
Help : "Total number of short API watches done by the reflectors" ,
87
97
}, []string {"name" })
88
98
89
- watchDuration = prometheus .NewSummaryVec (prometheus.SummaryOpts {
99
+ // WatchDuration is a prometheus metric tracking how long an API watch takes
100
+ // to return and decode for the reflectors.
101
+ WatchDuration = prometheus .NewSummaryVec (prometheus.SummaryOpts {
90
102
Subsystem : reflectorSubsystem ,
91
103
Name : "watch_duration_seconds" ,
92
104
Help : "How long an API watch takes to return and decode for the reflectors" ,
93
105
}, []string {"name" })
94
106
95
- itemsPerWatch = prometheus .NewSummaryVec (prometheus.SummaryOpts {
107
+ // ItemsPerWatch is a prometheus metric tracking how many items an API watch
108
+ // returns to the reflectors.
109
+ ItemsPerWatch = prometheus .NewSummaryVec (prometheus.SummaryOpts {
96
110
Subsystem : reflectorSubsystem ,
97
111
Name : "items_per_watch" ,
98
112
Help : "How many items an API watch returns to the reflectors" ,
99
113
}, []string {"name" })
100
114
101
- lastResourceVersion = prometheus .NewGaugeVec (prometheus.GaugeOpts {
115
+ // LastResourceVersion is a prometheus metric tracking the last resource version
116
+ // seen for the reflectors.
117
+ LastResourceVersion = prometheus .NewGaugeVec (prometheus.GaugeOpts {
102
118
Subsystem : reflectorSubsystem ,
103
119
Name : "last_resource_version" ,
104
120
Help : "Last resource version seen for the reflectors" ,
@@ -113,23 +129,23 @@ func init() {
113
129
// registerClientMetrics sets up the client latency metrics from client-go
114
130
func registerClientMetrics () {
115
131
// register the metrics with our registry
116
- Registry .MustRegister (requestLatency )
117
- Registry .MustRegister (requestResult )
132
+ Registry .MustRegister (RequestLatency )
133
+ Registry .MustRegister (RequestResult )
118
134
119
135
// register the metrics with client-go
120
- clientmetrics .Register (& latencyAdapter {metric : requestLatency }, & resultAdapter {metric : requestResult })
136
+ clientmetrics .Register (& latencyAdapter {metric : RequestLatency }, & resultAdapter {metric : RequestResult })
121
137
}
122
138
123
139
// registerReflectorMetrics sets up reflector (reconcile) loop metrics
124
140
func registerReflectorMetrics () {
125
- Registry .MustRegister (listsTotal )
126
- Registry .MustRegister (listsDuration )
127
- Registry .MustRegister (itemsPerList )
128
- Registry .MustRegister (watchesTotal )
129
- Registry .MustRegister (shortWatchesTotal )
130
- Registry .MustRegister (watchDuration )
131
- Registry .MustRegister (itemsPerWatch )
132
- Registry .MustRegister (lastResourceVersion )
141
+ Registry .MustRegister (ListsTotal )
142
+ Registry .MustRegister (ListsDuration )
143
+ Registry .MustRegister (ItemsPerList )
144
+ Registry .MustRegister (WatchesTotal )
145
+ Registry .MustRegister (ShortWatchesTotal )
146
+ Registry .MustRegister (WatchDuration )
147
+ Registry .MustRegister (ItemsPerWatch )
148
+ Registry .MustRegister (LastResourceVersion )
133
149
134
150
reflectormetrics .SetReflectorMetricsProvider (reflectorMetricsProvider {})
135
151
}
@@ -165,33 +181,33 @@ func (r *resultAdapter) Increment(code, method, host string) {
165
181
type reflectorMetricsProvider struct {}
166
182
167
183
func (reflectorMetricsProvider ) NewListsMetric (name string ) reflectormetrics.CounterMetric {
168
- return listsTotal .WithLabelValues (name )
184
+ return ListsTotal .WithLabelValues (name )
169
185
}
170
186
171
187
func (reflectorMetricsProvider ) NewListDurationMetric (name string ) reflectormetrics.SummaryMetric {
172
- return listsDuration .WithLabelValues (name )
188
+ return ListsDuration .WithLabelValues (name )
173
189
}
174
190
175
191
func (reflectorMetricsProvider ) NewItemsInListMetric (name string ) reflectormetrics.SummaryMetric {
176
- return itemsPerList .WithLabelValues (name )
192
+ return ItemsPerList .WithLabelValues (name )
177
193
}
178
194
179
195
func (reflectorMetricsProvider ) NewWatchesMetric (name string ) reflectormetrics.CounterMetric {
180
- return watchesTotal .WithLabelValues (name )
196
+ return WatchesTotal .WithLabelValues (name )
181
197
}
182
198
183
199
func (reflectorMetricsProvider ) NewShortWatchesMetric (name string ) reflectormetrics.CounterMetric {
184
- return shortWatchesTotal .WithLabelValues (name )
200
+ return ShortWatchesTotal .WithLabelValues (name )
185
201
}
186
202
187
203
func (reflectorMetricsProvider ) NewWatchDurationMetric (name string ) reflectormetrics.SummaryMetric {
188
- return watchDuration .WithLabelValues (name )
204
+ return WatchDuration .WithLabelValues (name )
189
205
}
190
206
191
207
func (reflectorMetricsProvider ) NewItemsInWatchMetric (name string ) reflectormetrics.SummaryMetric {
192
- return itemsPerWatch .WithLabelValues (name )
208
+ return ItemsPerWatch .WithLabelValues (name )
193
209
}
194
210
195
211
func (reflectorMetricsProvider ) NewLastResourceVersionMetric (name string ) reflectormetrics.GaugeMetric {
196
- return lastResourceVersion .WithLabelValues (name )
212
+ return LastResourceVersion .WithLabelValues (name )
197
213
}
0 commit comments