@@ -27,23 +27,21 @@ var (
2727 // All metrics are cumulative
2828
2929 // total amount of units credited
30- mBalanceCredit metrics.Counter
30+ mBalanceCredit = metrics .NewRegisteredCounterForced ( "account.balance.credit" , metrics . AccountingRegistry )
3131 // total amount of units debited
32- mBalanceDebit metrics.Counter
32+ mBalanceDebit = metrics .NewRegisteredCounterForced ( "account.balance.debit" , metrics . AccountingRegistry )
3333 // total amount of bytes credited
34- mBytesCredit metrics.Counter
34+ mBytesCredit = metrics .NewRegisteredCounterForced ( "account.bytes.credit" , metrics . AccountingRegistry )
3535 // total amount of bytes debited
36- mBytesDebit metrics.Counter
36+ mBytesDebit = metrics .NewRegisteredCounterForced ( "account.bytes.debit" , metrics . AccountingRegistry )
3737 // total amount of credited messages
38- mMsgCredit metrics.Counter
38+ mMsgCredit = metrics .NewRegisteredCounterForced ( "account.msg.credit" , metrics . AccountingRegistry )
3939 // total amount of debited messages
40- mMsgDebit metrics.Counter
40+ mMsgDebit = metrics .NewRegisteredCounterForced ( "account.msg.debit" , metrics . AccountingRegistry )
4141 // how many times local node had to drop remote peers
42- mPeerDrops metrics.Counter
42+ mPeerDrops = metrics .NewRegisteredCounterForced ( "account.peerdrops" , metrics . AccountingRegistry )
4343 // 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 )
4745)
4846
4947// Prices defines how prices are being passed on to the accounting instance
@@ -110,24 +108,13 @@ func NewAccounting(balance Balance, po Prices) *Accounting {
110108 return ah
111109}
112110
113- // SetupAccountingMetrics creates a separate registry for p2p accounting metrics;
111+ // SetupAccountingMetrics uses a separate registry for p2p accounting metrics;
114112// 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
116114// at the passed interval writes the metrics to a LevelDB
117115func 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 )
129116 // create the DB and start persisting
130- return NewAccountingMetrics (MetricsRegistry , reportInterval , path )
117+ return NewAccountingMetrics (metrics . AccountingRegistry , reportInterval , path )
131118}
132119
133120// Send takes a peer, a size and a msg and
0 commit comments