-
Notifications
You must be signed in to change notification settings - Fork 337
/
metrics.go
88 lines (82 loc) · 3 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
// 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 pullsync
import (
m "github.com/ethersphere/bee/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
Offered prometheus.Counter // number of chunks offered
Wanted prometheus.Counter // number of chunks wanted
MissingChunks prometheus.Counter // number of reserve get errs
ReceivedZeroAddress prometheus.Counter // number of delivered chunks with invalid address
ReceivedInvalidChunk prometheus.Counter // number of delivered chunks with invalid address
Delivered prometheus.Counter // number of chunk deliveries
Sent prometheus.Counter // number of chunks sent
DuplicateRuid prometheus.Counter // number of duplicate RUID requests we got
LastReceived *prometheus.CounterVec // last timestamp of the received chunks per bin
}
func newMetrics() metrics {
subsystem := "pullsync"
return metrics{
Offered: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "chunks_offered",
Help: "Total chunks offered.",
}),
Wanted: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "chunks_wanted",
Help: "Total chunks wanted.",
}),
MissingChunks: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "missing_chunks",
Help: "Total reserve get errors.",
}),
ReceivedZeroAddress: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "received_zero_address",
Help: "Total chunks delivered with zero address and no chunk data.",
}),
ReceivedInvalidChunk: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "received_invalid_chunks",
Help: "Total invalid chunks delivered.",
}),
Delivered: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "chunks_delivered",
Help: "Total chunks delivered.",
}),
Sent: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "chunks_sent",
Help: "Total chunks sent.",
}),
DuplicateRuid: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "duplicate_ruids",
Help: "Total duplicate RUIDs.",
}),
LastReceived: prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "last_received",
Help: `The last timestamp of the received chunks per bin.`,
}, []string{"bin"}),
}
}
func (s *Syncer) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(s.metrics)
}