feat(metrics): implement RAII-based block timing with Prometheus support#60
Merged
louisliu2048 merged 7 commits intodevfrom Dec 3, 2025
Merged
feat(metrics): implement RAII-based block timing with Prometheus support#60louisliu2048 merged 7 commits intodevfrom
louisliu2048 merged 7 commits intodevfrom
Conversation
louisliu2048
reviewed
Dec 3, 2025
|
|
||
| /// Manually finish timing and return the duration. | ||
| /// This updates the target immediately and prevents the drop handler from running. | ||
| pub fn finish(mut self) -> Duration { |
Collaborator
There was a problem hiding this comment.
The finish() method calls record(), and then when the guard is dropped, Drop::drop() calls record() again, resulting in Prometheus metrics being recorded twice.
| impl Drop for BlockTimingContext { | ||
| fn drop(&mut self) { | ||
| if self.auto_store { | ||
| self.update_totals(); |
Collaborator
There was a problem hiding this comment.
In crates/engine/tree/src/tree/mod.rs, update_totals() is called manually: timing_ctx.update_totals(), and then called again in this Drop implementation. This causes Prometheus total metrics to be recorded twice.
| /// These metrics track the duration of various phases in block production and insertion. | ||
| #[derive(Metrics, Clone)] | ||
| #[metrics(scope = "block.timing")] | ||
| pub struct BlockTimingPrometheusMetrics { |
Collaborator
There was a problem hiding this comment.
The current Prometheus metrics are global histograms without any labels to distinguish different scenarios. This makes it difficult to analyze metrics by:
- Block number
- Whether the block was locally built vs received from network
- Other contextual information
Collaborator
There was a problem hiding this comment.
recommend use dynamic labels to solve it.
added 2 commits
December 3, 2025 17:11
louisliu2048
approved these changes
Dec 3, 2025
Vui-Chee
added a commit
that referenced
this pull request
Dec 11, 2025
* dev: chore: Update cargo deps (#65) feat(flashblock): Enable eth_getTransactionByHash support for flashblock (paradigmxyz#19954) feat(flashblocks): Cache recent flashblocks (paradigmxyz#19786) feat(flashblock): improve state root calculation condition (paradigmxyz#19667) feat(flashblocks): add metrics for current block and index (paradigmxyz#19712) refactor(flashblock): Move all flashblocks related data structure to op-alloy (paradigmxyz#19608) chore: add target: flashblock for all flashblock related traces (paradigmxyz#19656) feat(metrics): implement RAII-based block timing with Prometheus support (#60) Fix fmt (#62)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.