Skip to content

Commit 827afdd

Browse files
committed
cmd: --metrics.statesize
Signed-off-by: jsvisa <[email protected]>
1 parent a766380 commit 827afdd

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

cmd/geth/config.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func constructDevModeBanner(ctx *cli.Context, cfg gethConfig) string {
209209
0x%x (10^49 ETH)
210210
`, cfg.Eth.Miner.PendingFeeRecipient)
211211
if cfg.Eth.Miner.PendingFeeRecipient == utils.DeveloperAddr {
212-
devModeBanner += fmt.Sprintf(`
212+
devModeBanner += fmt.Sprintf(`
213213
Private Key
214214
------------------
215215
0x%x
@@ -375,6 +375,9 @@ func applyMetricConfig(ctx *cli.Context, cfg *gethConfig) {
375375
if ctx.IsSet(utils.MetricsInfluxDBOrganizationFlag.Name) {
376376
cfg.Metrics.InfluxDBOrganization = ctx.String(utils.MetricsInfluxDBOrganizationFlag.Name)
377377
}
378+
if ctx.IsSet(utils.MetricsStateSizeFlag.Name) {
379+
cfg.Metrics.EnableStateSizeTracking = ctx.Bool(utils.MetricsStateSizeFlag.Name)
380+
}
378381
// Sanity-check the commandline flags. It is fine if some unused fields is part
379382
// of the toml-config, but we expect the commandline to only contain relevant
380383
// arguments, otherwise it indicates an error.

cmd/geth/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ var (
200200
utils.MetricsInfluxDBTokenFlag,
201201
utils.MetricsInfluxDBBucketFlag,
202202
utils.MetricsInfluxDBOrganizationFlag,
203+
utils.MetricsStateSizeFlag,
203204
}
204205
)
205206

cmd/utils/flags.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,13 @@ Please note that --` + MetricsHTTPFlag.Name + ` must be set to start the server.
966966
Value: metrics.DefaultConfig.InfluxDBOrganization,
967967
Category: flags.MetricsCategory,
968968
}
969+
970+
MetricsStateSizeFlag = &cli.BoolFlag{
971+
Name: "metrics.statesize",
972+
Usage: "Enable state size tracking for metrics collection",
973+
Value: metrics.DefaultConfig.EnableStateSizeTracking,
974+
Category: flags.MetricsCategory,
975+
}
969976
)
970977

971978
var (
@@ -2218,6 +2225,10 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
22182225
} else if ctx.IsSet(CacheFlag.Name) || ctx.IsSet(CacheSnapshotFlag.Name) {
22192226
options.SnapshotLimit = ctx.Int(CacheFlag.Name) * ctx.Int(CacheSnapshotFlag.Name) / 100
22202227
}
2228+
if ctx.Bool(MetricsStateSizeFlag.Name) {
2229+
log.Info("Enabling state size tracking")
2230+
options.EnableStateSizeTracking = true
2231+
}
22212232
// If we're in readonly, do not bother generating snapshot data.
22222233
if readonly {
22232234
options.SnapshotNoBuild = true

metrics/config.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ type Config struct {
3333
InfluxDBToken string `toml:",omitempty"`
3434
InfluxDBBucket string `toml:",omitempty"`
3535
InfluxDBOrganization string `toml:",omitempty"`
36+
37+
EnableStateSizeTracking bool `toml:",omitempty"`
3638
}
3739

3840
// DefaultConfig is the default config for metrics used in go-ethereum.
@@ -53,4 +55,6 @@ var DefaultConfig = Config{
5355
InfluxDBToken: "test",
5456
InfluxDBBucket: "geth",
5557
InfluxDBOrganization: "geth",
58+
59+
EnableStateSizeTracking: false,
5660
}

0 commit comments

Comments
 (0)