@@ -27,23 +27,21 @@ var (
27
27
// All metrics are cumulative
28
28
29
29
// total amount of units credited
30
- mBalanceCredit metrics.Counter
30
+ mBalanceCredit = metrics .NewRegisteredCounterForced ( "account.balance.credit" , metrics . AccountingRegistry )
31
31
// total amount of units debited
32
- mBalanceDebit metrics.Counter
32
+ mBalanceDebit = metrics .NewRegisteredCounterForced ( "account.balance.debit" , metrics . AccountingRegistry )
33
33
// total amount of bytes credited
34
- mBytesCredit metrics.Counter
34
+ mBytesCredit = metrics .NewRegisteredCounterForced ( "account.bytes.credit" , metrics . AccountingRegistry )
35
35
// total amount of bytes debited
36
- mBytesDebit metrics.Counter
36
+ mBytesDebit = metrics .NewRegisteredCounterForced ( "account.bytes.debit" , metrics . AccountingRegistry )
37
37
// total amount of credited messages
38
- mMsgCredit metrics.Counter
38
+ mMsgCredit = metrics .NewRegisteredCounterForced ( "account.msg.credit" , metrics . AccountingRegistry )
39
39
// total amount of debited messages
40
- mMsgDebit metrics.Counter
40
+ mMsgDebit = metrics .NewRegisteredCounterForced ( "account.msg.debit" , metrics . AccountingRegistry )
41
41
// how many times local node had to drop remote peers
42
- mPeerDrops metrics.Counter
42
+ mPeerDrops = metrics .NewRegisteredCounterForced ( "account.peerdrops" , metrics . AccountingRegistry )
43
43
// how many times local node overdrafted and dropped
44
- mSelfDrops metrics.Counter
45
-
46
- MetricsRegistry metrics.Registry
44
+ mSelfDrops = metrics .NewRegisteredCounterForced ("account.selfdrops" , metrics .AccountingRegistry )
47
45
)
48
46
49
47
// Prices defines how prices are being passed on to the accounting instance
@@ -110,24 +108,13 @@ func NewAccounting(balance Balance, po Prices) *Accounting {
110
108
return ah
111
109
}
112
110
113
- // SetupAccountingMetrics creates a separate registry for p2p accounting metrics;
111
+ // SetupAccountingMetrics uses a separate registry for p2p accounting metrics;
114
112
// this registry should be independent of any other metrics as it persists at different endpoints.
115
- // It also instantiates the given metrics and starts the persisting go-routine which
113
+ // It also starts the persisting go-routine which
116
114
// at the passed interval writes the metrics to a LevelDB
117
115
func SetupAccountingMetrics (reportInterval time.Duration , path string ) * AccountingMetrics {
118
- // create an empty registry
119
- MetricsRegistry = metrics .NewRegistry ()
120
- // instantiate the metrics
121
- mBalanceCredit = metrics .NewRegisteredCounterForced ("account.balance.credit" , MetricsRegistry )
122
- mBalanceDebit = metrics .NewRegisteredCounterForced ("account.balance.debit" , MetricsRegistry )
123
- mBytesCredit = metrics .NewRegisteredCounterForced ("account.bytes.credit" , MetricsRegistry )
124
- mBytesDebit = metrics .NewRegisteredCounterForced ("account.bytes.debit" , MetricsRegistry )
125
- mMsgCredit = metrics .NewRegisteredCounterForced ("account.msg.credit" , MetricsRegistry )
126
- mMsgDebit = metrics .NewRegisteredCounterForced ("account.msg.debit" , MetricsRegistry )
127
- mPeerDrops = metrics .NewRegisteredCounterForced ("account.peerdrops" , MetricsRegistry )
128
- mSelfDrops = metrics .NewRegisteredCounterForced ("account.selfdrops" , MetricsRegistry )
129
116
// create the DB and start persisting
130
- return NewAccountingMetrics (MetricsRegistry , reportInterval , path )
117
+ return NewAccountingMetrics (metrics . AccountingRegistry , reportInterval , path )
131
118
}
132
119
133
120
// Send takes a peer, a size and a msg and
0 commit comments