-
Notifications
You must be signed in to change notification settings - Fork 339
/
metrics.go
67 lines (61 loc) · 2.03 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
// 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
Delivered prometheus.Counter // number of chunk deliveries
DbOps prometheus.Counter // number of db ops
DuplicateRuid prometheus.Counter // number of duplicate RUID requests we got
LastReceived *prometheus.GaugeVec // 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.",
}),
Delivered: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "chunks_delivered",
Help: "Total chunks delivered.",
}),
DbOps: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "db_ops",
Help: "Total Db Ops.",
}),
DuplicateRuid: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "duplicate_ruids",
Help: "Total duplicate RUIDs.",
}),
LastReceived: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
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)
}