Cleanup logging

This commit is contained in:
Aditya Kulkarni 2021-07-28 19:34:41 -07:00
parent 1b485256a3
commit db02bf40b9
1 changed files with 10 additions and 11 deletions

View File

@ -295,30 +295,29 @@ func (s *lwdStreamer) GetBlockRange(span *walletrpc.BlockRange, resp walletrpc.C
} }
}() }()
// Log a daily active user if the user requests the day's "key block" // Logging and metrics
go func() { go func() {
// Log a daily active user if the user requests the day's "key block"
for height := span.Start.Height; height <= span.End.Height; height++ { for height := span.Start.Height; height <= span.End.Height; height++ {
s.dailyActiveBlock(height, peerip) s.dailyActiveBlock(height, peerip)
} }
}()
common.Log.WithFields(logrus.Fields{ common.Log.WithFields(logrus.Fields{
"method": "GetBlockRange", "method": "GetBlockRange",
"start": span.Start.Height, "start": span.Start.Height,
"end": span.End.Height, "end": span.End.Height,
"peer_addr": peerip, "peer_addr": peerip,
}).Info("Service") }).Info("Service")
common.Metrics.TotalBlocksServedConter.Add(math.Abs(float64(span.Start.Height) - float64(span.End.Height)))
}()
go common.GetBlockRange(s.cache, blockChan, errChan, int(span.Start.Height), int(span.End.Height)) go common.GetBlockRange(s.cache, blockChan, errChan, int(span.Start.Height), int(span.End.Height))
for { for {
select { select {
case err := <-errChan: case err := <-errChan:
// this will also catch context.DeadlineExceeded from the timeout
//common.Metrics.TotalErrors.Inc()
return err return err
case cBlock := <-blockChan: case cBlock := <-blockChan:
common.Metrics.TotalBlocksServedConter.Inc()
err := resp.Send(cBlock) err := resp.Send(cBlock)
if err != nil { if err != nil {
return err return err