Skip to content

Commit 1924a92

Browse files
author
Yutong Pei
authored
reduce some noisy log and add some metrics (iotexproject#61)
* reduce some noisy log and add some metrics
1 parent fbb19e8 commit 1924a92

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

actpool/actpool.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -521,7 +521,7 @@ func (ap *actPool) addAction(sender string, act *iproto.ActionPb, hash hash.Hash
521521

522522
if actNonce-queue.StartNonce() >= ap.cfg.MaxNumActsPerAcct {
523523
// Nonce exceeds current range
524-
logger.Warn().
524+
logger.Debug().
525525
Hex("hash", hash[:]).
526526
Uint64("startNonce", queue.StartNonce()).Uint64("actNonce", actNonce).
527527
Msg("Rejecting action because nonce is too large")

dispatch/dispatch.go

+19-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414

1515
"github.com/golang/protobuf/proto"
1616
"github.com/pkg/errors"
17+
"github.com/prometheus/client_golang/prometheus"
1718

1819
"github.com/iotexproject/iotex-core/actpool"
1920
"github.com/iotexproject/iotex-core/blockchain"
@@ -26,6 +27,18 @@ import (
2627
pb "github.com/iotexproject/iotex-core/proto"
2728
)
2829

30+
var requestMtc = prometheus.NewCounterVec(
31+
prometheus.CounterOpts{
32+
Name: "iotex_dispatch_request",
33+
Help: "Dispatcher request counter.",
34+
},
35+
[]string{"method", "succeed"},
36+
)
37+
38+
func init() {
39+
prometheus.MustRegister(requestMtc)
40+
}
41+
2942
// blockMsg packages a proto block message.
3043
type blockMsg struct {
3144
block *pb.BlockPb
@@ -176,19 +189,22 @@ func (d *IotxDispatcher) handleActionMsg(m *actionMsg) {
176189
tsf := &action.Transfer{}
177190
tsf.ConvertFromActionPb(m.action)
178191
if err := d.ap.AddTsf(tsf); err != nil {
179-
logger.Error().Err(err)
192+
requestMtc.WithLabelValues("addTsf", "false").Inc()
193+
logger.Debug().Err(err)
180194
}
181195
} else if pbVote := m.action.GetVote(); pbVote != nil {
182196
vote := &action.Vote{}
183197
vote.ConvertFromActionPb(m.action)
184198
if err := d.ap.AddVote(vote); err != nil {
185-
logger.Error().Err(err)
199+
requestMtc.WithLabelValues("addVote", "false").Inc()
200+
logger.Debug().Err(err)
186201
}
187202
} else if pbExecution := m.action.GetExecution(); pbExecution != nil {
188203
execution := &action.Execution{}
189204
execution.ConvertFromActionPb(m.action)
190205
if err := d.ap.AddExecution(execution); err != nil {
191-
logger.Error().Err(err).Msg("Failed to add execution")
206+
requestMtc.WithLabelValues("addExecution", "false").Inc()
207+
logger.Debug().Err(err).Msg("Failed to add execution")
192208
}
193209
}
194210
// signal to let caller know we are done

0 commit comments

Comments
 (0)