Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
tx-storm metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
sfxdxdev committed Nov 14, 2019
1 parent a35e858 commit db3e05d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/lachesis/metrics.go
Expand Up @@ -19,5 +19,5 @@ func SetupPrometheus(ctx *cli.Context) {
}

var endpoint = ctx.GlobalString(MetricsPrometheusEndpointFlag.Name)
prometheus.ListenTo(endpoint)
prometheus.ListenTo(endpoint, nil)
}
2 changes: 2 additions & 0 deletions cmd/tx-storm/feedback.go
Expand Up @@ -144,6 +144,8 @@ func (f *feedback) background(blocks chan<- big.Int) {
}

f.Log.Info(">>>>>>>>> GOT", "info", info)
txCountGotMeter.Inc(1)
txLatencyMeter.Update(time.Since(info.Created).Milliseconds() * 1000)
}
}

Expand Down
10 changes: 8 additions & 2 deletions cmd/tx-storm/metrics.go
Expand Up @@ -13,13 +13,19 @@ var MetricsPrometheusEndpointFlag = cli.StringFlag{
Value: ":19090",
}

var txCountMeter = metrics.NewRegisteredCounter("txn", nil)
var (
reg = metrics.NewRegistry()

txCountSentMeter = metrics.NewRegisteredCounter("tx_count_sent", reg)
txCountGotMeter = metrics.NewRegisteredCounter("tx_count_got", reg)
txLatencyMeter = metrics.NewRegisteredHistogram("tx_latency", reg, metrics.NewUniformSample(100))
)

func SetupPrometheus(ctx *cli.Context) {
if !metrics.Enabled {
return
}

var endpoint = ctx.GlobalString(MetricsPrometheusEndpointFlag.Name)
prometheus.ListenTo(endpoint)
prometheus.ListenTo(endpoint, reg)
}
2 changes: 1 addition & 1 deletion cmd/tx-storm/sender.go
Expand Up @@ -105,7 +105,7 @@ func (s *sender) background() {
cancel()
if err == nil {
s.Log.Info("tx sending ok", "info", info, "amount", tx.Raw.Value(), "nonce", tx.Raw.Nonce())
txCountMeter.Inc(1)
txCountSentMeter.Inc(1)
break sending
}

Expand Down
2 changes: 1 addition & 1 deletion docker/local-start.sh
Expand Up @@ -17,7 +17,7 @@ do
--datadir=${DATADIR} \
--fakenet $i/$N,100000 \
--port $((5050+i)) --rpc --rpcaddr 127.0.0.1 --rpcport $((4000+i)) --rpccorsdomain "*" --rpcapi "eth,debug,admin,web3" \
--nousb --verbosity 5 --metrics &> .lachesis$i.log)&
--nousb --verbosity 5 &> .lachesis$i.log)&
done

attach_and_exec() {
Expand Down
6 changes: 4 additions & 2 deletions metrics/prometheus/handler.go
Expand Up @@ -11,8 +11,10 @@ import (

var logger = log.New("module", "prometheus")

func ListenTo(endpoint string) {
reg := metrics.DefaultRegistry
func ListenTo(endpoint string, reg metrics.Registry) {
if reg == nil {
reg = metrics.DefaultRegistry
}
reg.Each(collect)

go func() {
Expand Down

0 comments on commit db3e05d

Please sign in to comment.