-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
60 lines (54 loc) · 1.75 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
/*
Copyright IBM Corp. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0
*/
package smartbft
import "github.com/hyperledger/fabric/common/metrics"
var (
clusterSizeOpts = metrics.GaugeOpts{
Namespace: "consensus",
Subsystem: "smartbft",
Name: "cluster_size",
Help: "Number of nodes in this channel.",
LabelNames: []string{"channel"},
StatsdFormat: "%{#fqname}.%{channel}",
}
committedBlockNumberOpts = metrics.GaugeOpts{
Namespace: "consensus",
Subsystem: "smartbft",
Name: "committed_block_number",
Help: "The number of the latest committed block.",
LabelNames: []string{"channel"},
StatsdFormat: "%{#fqname}.%{channel}",
}
isLeaderOpts = metrics.GaugeOpts{
Namespace: "consensus",
Subsystem: "smartbft",
Name: "is_leader",
Help: "The leadership status of the current node according to the latest committed block: 1 if it is the leader else 0.",
LabelNames: []string{"channel"},
StatsdFormat: "%{#fqname}.%{channel}",
}
leaderIDOpts = metrics.GaugeOpts{
Namespace: "consensus",
Subsystem: "smartbft",
Name: "leader_id",
Help: "The id of the current leader according to the latest committed block.",
LabelNames: []string{"channel"},
StatsdFormat: "%{#fqname}.%{channel}",
}
)
type Metrics struct {
ClusterSize metrics.Gauge
CommittedBlockNumber metrics.Gauge
IsLeader metrics.Gauge
LeaderID metrics.Gauge
}
func NewMetrics(p metrics.Provider) *Metrics {
return &Metrics{
ClusterSize: p.NewGauge(clusterSizeOpts),
CommittedBlockNumber: p.NewGauge(committedBlockNumberOpts),
IsLeader: p.NewGauge(isLeaderOpts),
LeaderID: p.NewGauge(leaderIDOpts),
}
}