@@ -14,6 +14,7 @@ import (
14
14
15
15
"github.com/golang/protobuf/proto"
16
16
"github.com/pkg/errors"
17
+ "github.com/prometheus/client_golang/prometheus"
17
18
18
19
"github.com/iotexproject/iotex-core/actpool"
19
20
"github.com/iotexproject/iotex-core/blockchain"
@@ -26,6 +27,18 @@ import (
26
27
pb "github.com/iotexproject/iotex-core/proto"
27
28
)
28
29
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
+
29
42
// blockMsg packages a proto block message.
30
43
type blockMsg struct {
31
44
block * pb.BlockPb
@@ -176,19 +189,22 @@ func (d *IotxDispatcher) handleActionMsg(m *actionMsg) {
176
189
tsf := & action.Transfer {}
177
190
tsf .ConvertFromActionPb (m .action )
178
191
if err := d .ap .AddTsf (tsf ); err != nil {
179
- logger .Error ().Err (err )
192
+ requestMtc .WithLabelValues ("addTsf" , "false" ).Inc ()
193
+ logger .Debug ().Err (err )
180
194
}
181
195
} else if pbVote := m .action .GetVote (); pbVote != nil {
182
196
vote := & action.Vote {}
183
197
vote .ConvertFromActionPb (m .action )
184
198
if err := d .ap .AddVote (vote ); err != nil {
185
- logger .Error ().Err (err )
199
+ requestMtc .WithLabelValues ("addVote" , "false" ).Inc ()
200
+ logger .Debug ().Err (err )
186
201
}
187
202
} else if pbExecution := m .action .GetExecution (); pbExecution != nil {
188
203
execution := & action.Execution {}
189
204
execution .ConvertFromActionPb (m .action )
190
205
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" )
192
208
}
193
209
}
194
210
// signal to let caller know we are done
0 commit comments