/
metrics.go
380 lines (368 loc) · 13.8 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package localstore
import (
m "github.com/newswarm-lab/new-bee/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
TotalTimeGCLock prometheus.Counter
TotalTimeGCFirstItem prometheus.Counter
TotalTimeCollectGarbage prometheus.Counter
TotalTimeGCExclude prometheus.Counter
TotalTimeGet prometheus.Counter
TotalTimeUpdateGC prometheus.Counter
TotalTimeGetMulti prometheus.Counter
TotalTimeHas prometheus.Counter
TotalTimeHasMulti prometheus.Counter
TotalTimePut prometheus.Counter
TotalTimeSet prometheus.Counter
TotalTimeSubscribePullIteration prometheus.Counter
TotalTimeSubscribePushIteration prometheus.Counter
GCCounter prometheus.Counter
GCErrorCounter prometheus.Counter
GCCollectedCounter prometheus.Counter
GCCommittedCounter prometheus.Counter
GCExcludeCounter prometheus.Counter
GCExcludeError prometheus.Counter
GCExcludeWriteBatchError prometheus.Counter
GCUpdate prometheus.Counter
GCUpdateError prometheus.Counter
ModeGet prometheus.Counter
ModeGetFailure prometheus.Counter
ModeGetMulti prometheus.Counter
ModeGetMultiFailure prometheus.Counter
ModePut prometheus.Counter
ModePutFailure prometheus.Counter
ModeSet prometheus.Counter
ModeSetFailure prometheus.Counter
ModeHas prometheus.Counter
ModeHasFailure prometheus.Counter
ModeHasMulti prometheus.Counter
ModeHasMultiFailure prometheus.Counter
SubscribePull prometheus.Counter
SubscribePullStop prometheus.Counter
SubscribePullIteration prometheus.Counter
SubscribePullIterationFailure prometheus.Counter
LastPullSubscriptionBinID prometheus.Counter
SubscribePush prometheus.Counter
SubscribePushIteration prometheus.Counter
SubscribePushIterationDone prometheus.Counter
SubscribePushIterationFailure prometheus.Counter
GCSize prometheus.Gauge
GCStoreTimeStamps prometheus.Gauge
GCStoreAccessTimeStamps prometheus.Gauge
ReserveSize prometheus.Gauge
EvictReserveCounter prometheus.Counter
EvictReserveErrorCounter prometheus.Counter
TotalTimeEvictReserve prometheus.Counter
}
func newMetrics() metrics {
subsystem := "localstore"
return metrics{
TotalTimeGCLock: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_lock_time",
Help: "Total time under lock in gc.",
}),
TotalTimeGCFirstItem: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_first_item_time",
Help: "Total time taken till first item in gc comes out of gcIndex iterator.",
}),
TotalTimeCollectGarbage: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_time",
Help: "Total time taken to collect garbage.",
}),
TotalTimeGCExclude: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_exclude_index_time",
Help: "Total time taken to exclude gc index.",
}),
TotalTimeGet: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "get_chunk_time",
Help: "Total time taken to get chunk from DB.",
}),
TotalTimeUpdateGC: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "in_gc_time",
Help: "Total time taken to in gc.",
}),
TotalTimeGetMulti: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "get_multi_time",
Help: "Total time taken to get multiple chunks from DB.",
}),
TotalTimeHas: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "has_time",
Help: "Total time taken to check if the key is present in DB.",
}),
TotalTimeHasMulti: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "has_multi_time",
Help: "Total time taken to check if multiple keys are present in DB.",
}),
TotalTimePut: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "put_time",
Help: "Total time taken to put a chunk in DB.",
}),
TotalTimeSet: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "set_time",
Help: "Total time taken to set chunk in DB.",
}),
TotalTimeSubscribePullIteration: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_pull_iteration_time",
Help: "Total time taken to subsctibe for pull iteration.",
}),
TotalTimeSubscribePushIteration: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_push_iteration_time",
Help: "Total time taken to subscribe for push iteration.",
}),
GCCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_count",
Help: "Number of times the GC operation is done.",
}),
GCErrorCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_fail_count",
Help: "Number of times the GC operation failed.",
}),
GCCollectedCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_collected_count",
Help: "Number of times the GC_COLLECTED operation is done.",
}),
GCCommittedCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_committed_count",
Help: "Number of gc items to commit.",
}),
GCExcludeCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_exclude_count",
Help: "Number of times the GC_EXCLUDE operation is done.",
}),
GCExcludeError: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_exclude_fail_count",
Help: "Number of times the GC_EXCLUDE operation failed.",
}),
GCExcludeWriteBatchError: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "ex_exclude_write_batch_fail_count",
Help: "Number of times the GC_EXCLUDE_WRITE_BATCH operation is failed.",
}),
GCUpdate: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_update_count",
Help: "Number of times the gc is updated.",
}),
GCUpdateError: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_update_error_count",
Help: "Number of times the gc update had error.",
}),
ModeGet: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_get_count",
Help: "Number of times MODE_GET is invoked.",
}),
ModeGetFailure: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_get_failure_count",
Help: "Number of times MODE_GET invocation failed.",
}),
ModeGetMulti: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_get_multi_count",
Help: "Number of times MODE_MULTI_GET is invoked.",
}),
ModeGetMultiFailure: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_get_multi_failure_count",
Help: "Number of times MODE_GET invocation failed.",
}),
ModePut: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_put_count",
Help: "Number of times MODE_PUT is invoked.",
}),
ModePutFailure: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_put_failure_count",
Help: "Number of times MODE_PUT invocation failed.",
}),
ModeSet: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_set_count",
Help: "Number of times MODE_SET is invoked.",
}),
ModeSetFailure: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_set_failure_count",
Help: "Number of times MODE_SET invocation failed.",
}),
ModeHas: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_has_count",
Help: "Number of times MODE_HAS is invoked.",
}),
ModeHasFailure: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_has_failure_count",
Help: "Number of times MODE_HAS invocation failed.",
}),
ModeHasMulti: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_has_multi_count",
Help: "Number of times MODE_HAS_MULTI is invoked.",
}),
ModeHasMultiFailure: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "mode_has_multi_failure_count",
Help: "Number of times MODE_HAS_MULTI invocation failed.",
}),
SubscribePull: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_pull_count",
Help: "Number of times Subscribe_pULL is invoked.",
}),
SubscribePullStop: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_pull_stop_count",
Help: "Number of times Subscribe_pull_stop is invoked.",
}),
SubscribePullIteration: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_pull_iteration_count",
Help: "Number of times Subscribe_pull_iteration is invoked.",
}),
SubscribePullIterationFailure: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_pull_iteration_fail_count",
Help: "Number of times Subscribe_pull_iteration_fail is invoked.",
}),
LastPullSubscriptionBinID: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "last_pull_subscription_bin_id_count",
Help: "Number of times LastPullSubscriptionBinID is invoked.",
}),
SubscribePush: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_push_count",
Help: "Number of times SUBSCRIBE_PUSH is invoked.",
}),
SubscribePushIteration: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_push_iteration_count",
Help: "Number of times SUBSCRIBE_PUSH_ITERATION is invoked.",
}),
SubscribePushIterationDone: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_push_iteration_done_count",
Help: "Number of times SUBSCRIBE_PUSH_ITERATION_DONE is invoked.",
}),
SubscribePushIterationFailure: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "subscribe_push_iteration_failure_count",
Help: "Number of times SUBSCRIBE_PUSH_ITERATION_FAILURE is invoked.",
}),
GCSize: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_size",
Help: "Number of elements in Garbage collection index.",
}),
GCStoreTimeStamps: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_time_stamp",
Help: "Storage timestamp in Garbage collection iteration.",
}),
GCStoreAccessTimeStamps: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "gc_access_time_stamp",
Help: "Access timestamp in Garbage collection iteration.",
}),
ReserveSize: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "reserve_size",
Help: "Number of elements in reserve.",
}),
EvictReserveCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "evict_reserve_count",
Help: "number of times the evict reserve worker was invoked",
}),
EvictReserveErrorCounter: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "evict_reserve_err_count",
Help: "number of times evict reserve got an error",
}),
TotalTimeEvictReserve: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "evict_reserve_total_time",
Help: "total time spent evicting from reserve",
}),
}
}
func (db *DB) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(db.metrics)
}