Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -2785,6 +2785,10 @@ func (app *App) checkTotalBlockGas(ctx sdk.Context, typedTxs []sdk.Tx) (result b
}
}

appMetrics.blockGasWanted.Record(ctx.Context(), int64(totalGasWanted)) //nolint:gosec
if cp := ctx.ConsensusParams(); cp != nil && cp.Block != nil && cp.Block.MaxGasWanted > 0 {
appMetrics.blockGasWantedRatio.Record(ctx.Context(), float64(totalGasWanted)/float64(cp.Block.MaxGasWanted))
}
return true
}

Expand Down
32 changes: 32 additions & 0 deletions app/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,20 @@ var (
0.000025, 0.000050, 0.0001, 0.0005, 0.001, 0.0025, 0.005, 0.010, 0.020, 0.050, 0.075, 0.1, 0.25, 0.5, 1, 10,
)

// blockGasWantedBuckets covers the 0–50 M gas range (current MaxGasWanted cap) with
// 1 M steps up to 10 M and 5 M steps thereafter so both lightly- and heavily-loaded
// blocks get useful quantiles.
blockGasWantedBuckets = metric.WithExplicitBucketBoundaries(
1e6, 2e6, 3e6, 4e6, 5e6, 6e6, 7e6, 8e6, 9e6, 10e6,
15e6, 20e6, 25e6, 30e6, 35e6, 40e6, 45e6, 50e6,
)

// blockGasWantedRatioBuckets covers the 0.0–1.0 utilisation range so we can see
// how close blocks are to the MaxGasWanted cap.
blockGasWantedRatioBuckets = metric.WithExplicitBucketBoundaries(
0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 0.95, 1.0,
)

appMetrics = struct {
// ABCI phase durations
beginBlockDuration metric.Float64Histogram
Expand All @@ -50,6 +64,10 @@ var (
failedGasWantedCheck metric.Int64Counter
gigaFallback metric.Int64Counter

// Per-block gas utilisation
blockGasWanted metric.Int64Histogram
blockGasWantedRatio metric.Float64Histogram

// Light invariance check
invarianceDuration metric.Float64Histogram
invarianceInvalidKey metric.Int64Counter
Expand Down Expand Up @@ -149,6 +167,20 @@ var (
metric.WithUnit("{count}"),
)),

blockGasWanted: must(meter.Int64Histogram(
"app_block_gas_wanted",
metric.WithDescription("Per-block total gas wanted across all transactions"),
metric.WithUnit("{gas}"),
blockGasWantedBuckets,
)),

blockGasWantedRatio: must(meter.Float64Histogram(
"app_block_gas_wanted_ratio",
metric.WithDescription("Per-block ratio of total gas wanted to MaxGasWanted consensus parameter"),
metric.WithUnit("1"),
blockGasWantedRatioBuckets,
)),

invarianceDuration: must(meter.Float64Histogram(
"app_lightinvariance_supply_duration",
metric.WithDescription("Duration of light invariance total supply check"),
Expand Down
Loading