@@ -3,7 +3,8 @@ package metrics
3
3
import (
4
4
"encoding/json"
5
5
"fmt"
6
- "log"
6
+
7
+ log "github.com/sirupsen/logrus"
7
8
8
9
"github.com/chia-network/go-chia-libs/pkg/rpc"
9
10
"github.com/chia-network/go-chia-libs/pkg/types"
@@ -144,12 +145,12 @@ func (s *FullNodeServiceMetrics) GetBlockchainState(resp *types.WebsocketRespons
144
145
state := & types.WebsocketBlockchainState {}
145
146
err := json .Unmarshal (resp .Data , state )
146
147
if err != nil {
147
- log .Printf ("Error unmarshalling: %s\n " , err .Error ())
148
+ log .Errorf ("Error unmarshalling: %s\n " , err .Error ())
148
149
return
149
150
}
150
151
151
152
if state .BlockchainState .Sync != nil {
152
- if state .BlockchainState .Sync .Synced == true {
153
+ if state .BlockchainState .Sync .Synced {
153
154
s .nodeSynced .Set (1 )
154
155
} else {
155
156
s .nodeSynced .Set (0 )
@@ -185,7 +186,7 @@ func (s *FullNodeServiceMetrics) GetConnections(resp *types.WebsocketResponse) {
185
186
connections := & rpc.GetConnectionsResponse {}
186
187
err := json .Unmarshal (resp .Data , connections )
187
188
if err != nil {
188
- log .Printf ("Error unmarshalling: %s\n " , err .Error ())
189
+ log .Errorf ("Error unmarshalling: %s\n " , err .Error ())
189
190
return
190
191
}
191
192
@@ -228,13 +229,13 @@ func (s *FullNodeServiceMetrics) Block(resp *types.WebsocketResponse) {
228
229
block := & types.BlockEvent {}
229
230
err := json .Unmarshal (resp .Data , block )
230
231
if err != nil {
231
- log .Printf ("Error unmarshalling: %s\n " , err .Error ())
232
+ log .Errorf ("Error unmarshalling: %s\n " , err .Error ())
232
233
return
233
234
}
234
235
235
236
s .kSize .WithLabelValues (fmt .Sprintf ("%d" , block .KSize )).Inc ()
236
237
237
- if block .TransactionBlock == true {
238
+ if block .TransactionBlock {
238
239
s .blockCost .Set (float64 (block .BlockCost ))
239
240
s .blockFees .Set (float64 (block .BlockFees ))
240
241
}
@@ -246,7 +247,7 @@ func (s *FullNodeServiceMetrics) GetBlockCountMetrics(resp *types.WebsocketRespo
246
247
blockMetrics := & rpc.GetBlockCountMetricsResponse {}
247
248
err := json .Unmarshal (resp .Data , blockMetrics )
248
249
if err != nil {
249
- log .Printf ("Error unmarshalling: %s\n " , err .Error ())
250
+ log .Errorf ("Error unmarshalling: %s\n " , err .Error ())
250
251
return
251
252
}
252
253
@@ -262,7 +263,7 @@ func (s *FullNodeServiceMetrics) SignagePoint(resp *types.WebsocketResponse) {
262
263
signagePoint := & types.SignagePointEvent {}
263
264
err := json .Unmarshal (resp .Data , signagePoint )
264
265
if err != nil {
265
- log .Printf ("Error unmarshalling: %s\n " , err .Error ())
266
+ log .Errorf ("Error unmarshalling: %s\n " , err .Error ())
266
267
return
267
268
}
268
269
0 commit comments