Skip to content

Commit

Permalink
metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
manojkgorle committed Jul 19, 2024
1 parent 096ab15 commit b3670ca
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 3 deletions.
5 changes: 2 additions & 3 deletions cmd/token-cli/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,21 +184,20 @@ func init() {
)
spamCmd.AddCommand(
runSpamCmd,
//runSpamSequencerMsgCmd,
runLocalFeeMarketCmd,
)

// prometheus
generatePrometheusCmd.PersistentFlags().StringVar(
&prometheusBaseURI,
"prometheus-base-uri",
"http://localhost:9090",
"http://localhost:9096",
"prometheus server location",
)
generatePrometheusCmd.PersistentFlags().BoolVar(
&prometheusOpenBrowser,
"prometheus-open-browser",
true,
false,
"open browser to prometheus dashboard",
)
generatePrometheusCmd.PersistentFlags().StringVar(
Expand Down
6 changes: 6 additions & 0 deletions controller/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ func (c *Controller) Accepted(ctx context.Context, blk *chain.StatelessBlock) er
c.metrics.transfer.Inc()
case *actions.SequencerMsg:
c.metrics.sequencerMsg.Inc()
case *actions.Oracle:
c.metrics.oracle.Inc()
case *actions.Deploy:
c.metrics.deploy.Inc()
case *actions.Transact:
c.metrics.transact.Inc()
}
}
}
Expand Down
28 changes: 28 additions & 0 deletions controller/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ type metrics struct {
transfer prometheus.Counter

sequencerMsg prometheus.Counter

oracle prometheus.Counter

deploy prometheus.Counter
transact prometheus.Counter
}

func newMetrics(gatherer ametrics.MultiGatherer) (*metrics, error) {
Expand Down Expand Up @@ -48,6 +53,24 @@ func newMetrics(gatherer ametrics.MultiGatherer) (*metrics, error) {
Name: "sequencer_msg",
Help: "number of sequencer msg actions",
}),

oracle: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "actions",
Name: "oracle",
Help: "number of oracle actions",
}),

deploy: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "actions",
Name: "deploy",
Help: "number of deploy actions",
}),

transact: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "actions",
Name: "transact",
Help: "number of transact actions",
}),
}
r := prometheus.NewRegistry()
errs := wrappers.Errs{}
Expand All @@ -59,6 +82,11 @@ func newMetrics(gatherer ametrics.MultiGatherer) (*metrics, error) {
r.Register(m.transfer),

r.Register(m.sequencerMsg),

r.Register(m.oracle),

r.Register(m.deploy),
r.Register(m.transact),
gatherer.Register(consts.Name, r),
)
return m, errs.Err
Expand Down

0 comments on commit b3670ca

Please sign in to comment.