Skip to content

Commit

Permalink
metrics: add txpool config into metrics server (#32)
Browse files Browse the repository at this point in the history
### Description

upstream PR bnb-chain#1788

add TxPool info into metrics server

### Changes

* cmd/utils/flags.go
* cmd/geth/config.go

Co-authored-by: Eric <45141191+zzphust@users.noreply.github.com>
  • Loading branch information
0xcb9ff9 and zlacfzy authored Sep 12, 2023
1 parent 8c07b95 commit 416e1b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/geth/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,7 @@ func makeFullNode(ctx *cli.Context) (*node.Node, ethapi.Backend) {
utils.SetupMetrics(ctx,
utils.EnableBuildInfo(gitCommit, gitDate),
utils.EnableMinerInfo(ctx, cfg.Eth.Miner),
utils.EnableNodeInfo(cfg.Eth.TxPool),
)
return stack, backend
}
Expand Down
15 changes: 15 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1919,6 +1919,21 @@ func EnableMinerInfo(ctx *cli.Context, minerConfig miner.Config) SetupMetricsOpt
}
}

func EnableNodeInfo(poolConfig core.TxPoolConfig) SetupMetricsOption {
return func() {
// register node info into metrics
metrics.NewRegisteredLabel("node-info", nil).Mark(map[string]interface{}{
"PriceLimit": poolConfig.PriceLimit,
"PriceBump": poolConfig.PriceBump,
"AccountSlots": poolConfig.AccountSlots,
"GlobalSlots": poolConfig.GlobalSlots,
"AccountQueue": poolConfig.AccountQueue,
"GlobalQueue": poolConfig.GlobalQueue,
"Lifetime": poolConfig.Lifetime,
})
}
}

func SetupMetrics(ctx *cli.Context, options ...SetupMetricsOption) {
if metrics.Enabled {
log.Info("Enabling metrics collection")
Expand Down

0 comments on commit 416e1b3

Please sign in to comment.