Skip to content

metrics(app): add app_block_gas_wanted and app_block_gas_wanted_ratio histograms (PLT-354)#3479

Merged
amir-deris merged 6 commits into
mainfrom
amir/plt-354-emit-block-gas-metrics
May 22, 2026
Merged

metrics(app): add app_block_gas_wanted and app_block_gas_wanted_ratio histograms (PLT-354)#3479
amir-deris merged 6 commits into
mainfrom
amir/plt-354-emit-block-gas-metrics

Conversation

@amir-deris

@amir-deris amir-deris commented May 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds two OTel histogram instruments to make per-block gas utilisation observable — answering "how close are blocks getting to the MaxGasWanted cap in practice" without offline block parsing.

  • app_block_gas_wanted (Int64Histogram, unit {gas}) — absolute totalGasWanted summed across all transactions in an accepted proposal
  • app_block_gas_wanted_ratio (Float64Histogram, unit 1) — totalGasWanted / MaxGasWanted, stays meaningful if the cap is raised via governance

Both are emitted in checkTotalBlockGas (app/app.go) on the success path only — the function already short-circuits with return false when the sum exceeds the cap, so only complete, accepted totals are recorded. The existing app_failed_total_gas_wanted_check counter covers rejection events.

Bucket boundaries:

  • Gas: 1 M–10 M in 1 M steps, then 5 M steps to 50 M (current cap)
  • Ratio: 0.1 steps from 0.1 → 0.9, plus 0.95 and 1.0

Closes PLT-354.

Test plan

  • Deploy to a test node and verify app_block_gas_wanted_bucket and app_block_gas_wanted_ratio_bucket appear in the Prometheus scrape. Can use this p50 query in Grafana by running
    histogram_quantile(0.5, rate({__name__="sei-chain_app_block_gas_wanted_ratio_bucket"}[10m]))
  • Confirm values are non-zero and ratio stays ≤ 1.0 under normal load

@cursor

cursor Bot commented May 20, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Low risk: adds new OpenTelemetry histogram instruments and records them on the successful checkTotalBlockGas path, without changing acceptance/rejection logic.

Overview
Adds two new OTel histograms—app_block_gas_wanted (absolute total gas wanted per accepted proposal) and app_block_gas_wanted_ratio (utilisation vs MaxGasWanted)—with explicit bucket boundaries tuned for current gas caps.

Emits these metrics from checkTotalBlockGas in app/app.go only after the proposal passes gas-limit checks (and guards ratio recording against missing/zero consensus params).

Reviewed by Cursor Bugbot for commit 051930a. Bugbot is set up for automated code reviews on this repo. Configure here.

@github-actions

github-actions Bot commented May 20, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow Buf / buf (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedMay 22, 2026, 7:56 AM

@amir-deris amir-deris changed the title Added new block gas metrics metrics(app): add app_block_gas_wanted and app_block_gas_wanted_ratio histograms (PLT-354) May 20, 2026
@codecov

codecov Bot commented May 20, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 59.14%. Comparing base (d4fc9c5) to head (051930a).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3479      +/-   ##
==========================================
+ Coverage   59.11%   59.14%   +0.02%     
==========================================
  Files        2187     2186       -1     
  Lines      182237   181999     -238     
==========================================
- Hits       107730   107635      -95     
+ Misses      64851    64718     -133     
+ Partials     9656     9646      -10     
Flag Coverage Δ
sei-chain-pr 50.58% <100.00%> (?)
sei-db 70.41% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
app/app.go 69.33% <100.00%> (-0.07%) ⬇️
app/metrics.go 15.38% <ø> (ø)

... and 43 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@amir-deris amir-deris requested review from bdchatham and masih May 20, 2026 23:35
Comment thread app/metrics.go Outdated
metric.WithUnit("{count}"),
)),

blockGasWanted: must(meter.Float64Histogram(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: does this need to be a float?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I will convert to Int64Histogram for better semantics.

@bdchatham bdchatham left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like the PR description is slightly stale

@amir-deris amir-deris added this pull request to the merge queue May 22, 2026
Merged via the queue into main with commit 67f1c97 May 22, 2026
49 of 50 checks passed
@amir-deris amir-deris deleted the amir/plt-354-emit-block-gas-metrics branch May 22, 2026 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants