-
Notifications
You must be signed in to change notification settings - Fork 132
feat(l1): add rpc error rates to metrics and panels #5335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 42 commits
Commits
Show all changes
53 commits
Select commit
Hold shift + click to select a range
8e6dc0b
add namespace to profiling
rodrigo-o 5b5e3d6
initial testing of instumentation
rodrigo-o 042b266
remove rpc namespaced instrumentation from breakdown panels
rodrigo-o e873b85
initial rpc dashboards
rodrigo-o cc97128
made some organization changes in the dashboard
rodrigo-o 14dbeaf
make rpc dashboard repeatable by instance
rodrigo-o 01bab1e
Merge branch 'main' into rpc-instrumentation-and-panels
rodrigo-o 6dc47b9
separate Engine API from RPC API in instrumentation
rodrigo-o d0885bb
change total sum by average in pie charts of rpc
rodrigo-o 6f82153
move from increase to rate for calculating the avg
rodrigo-o 1b6cefa
go without any increase or rate
rodrigo-o c7d20d6
rework panels for engine api
rodrigo-o fe92933
reworked the RPC api panels
rodrigo-o bc00add
Added instances to the rpc and engine panels
rodrigo-o 86fccd8
remove unintended overrides
rodrigo-o 5968fd3
remove intemediary doc
rodrigo-o f75a0ac
initial rework of the instrumentation to avoid complex observers in p…
rodrigo-o 6c4a9f5
go back to use just call to avoid most of rpc.rs changes made
rodrigo-o 024b3f7
Add namespace to profiling and explicitly set it up in the previous i…
rodrigo-o c51eeea
fixed an issue with the way namespace is send through #instrument
rodrigo-o 35d9cbd
Merge branch 'main' into rpc-instrumentation-and-panels
rodrigo-o 28ec41f
enhanced record_debug and remove magic namespacing given targets
rodrigo-o 6e5b041
format
rodrigo-o f6a401b
apply suggestions
rodrigo-o cd1534d
missed suggestions
rodrigo-o 2948d97
updated cargo lock for l2 quote-gen
rodrigo-o 39bd789
remove Cow given that it was already cloning
rodrigo-o 5b167ab
Add comment about why we use String instead of &'static str in the na…
rodrigo-o 7bece1b
Add rpc results and refactor rpc instrumentation to be aoutside of pr…
rodrigo-o 20c57b3
first error rates panel addition
rodrigo-o 609318b
Enhancement to panel placing across the RPC and engine rows
rodrigo-o b1a170e
Merge branch 'main' into rpc_error_rates
rodrigo-o ca2d22b
move some panels from rpc and engine from 5m to instead
rodrigo-o e890efa
limit the life of exetension to the let timer block
rodrigo-o f569eaf
Merge branch 'rpc-instrumentation-and-panels' into rpc_error_rates
rodrigo-o 91223a7
Merge branch 'main' into rpc_error_rates
rodrigo-o bb58393
updated references to rpc_request instead of the oldi functions
rodrigo-o 87b639c
Readded engine success/error rate and fixed some dashboard issues
rodrigo-o 12b9b28
Merge branch 'main' into rpc_error_rates
rodrigo-o d4d70a1
removed registry and moved the function to mod
rodrigo-o e17ef12
fix an unnecesary diff
rodrigo-o 7f34016
small change for consistency
rodrigo-o b609274
simplify record_async_duration documentation
rodrigo-o 8fb43a8
Merge branch 'main' into rpc_error_rates
rodrigo-o 0b6f697
Change function_name for method to avoid changes in future PRs
rodrigo-o 73a355a
Change title to reflect panels correctly
rodrigo-o 1329b03
updated documentation
rodrigo-o cdf40a3
Merge branch 'main' into rpc_error_rates
rodrigo-o 2ffb1cf
Merge branch 'main' into rpc_error_rates
rodrigo-o 20b971a
fix after merge
rodrigo-o ea64d05
formatting
rodrigo-o 108536d
chore(l1): enhance error rate panels and promote them to its own row …
rodrigo-o 9611ee5
use static str as error
rodrigo-o File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| use prometheus::{CounterVec, HistogramVec, register_counter_vec, register_histogram_vec}; | ||
| use std::{future::Future, sync::LazyLock}; | ||
|
|
||
| pub static METRICS_RPC_REQUEST_OUTCOMES: LazyLock<CounterVec> = | ||
| LazyLock::new(initialize_rpc_outcomes_counter); | ||
|
|
||
| pub static METRICS_RPC_DURATION: LazyLock<HistogramVec> = | ||
| LazyLock::new(initialize_rpc_duration_histogram); | ||
|
|
||
| // Metrics defined in this module register into the Prometheus default registry. | ||
| // The metrics API exposes them by calling `gather_default_metrics()`. | ||
|
|
||
| fn initialize_rpc_outcomes_counter() -> CounterVec { | ||
| register_counter_vec!( | ||
| "rpc_requests_total", | ||
| "Total number of RPC requests partitioned by namespace, method, and outcome", | ||
| &["namespace", "function_name", "outcome"], | ||
| ) | ||
| .unwrap() | ||
| } | ||
|
|
||
| fn initialize_rpc_duration_histogram() -> HistogramVec { | ||
| register_histogram_vec!( | ||
| "rpc_request_duration_seconds", | ||
| "Histogram of RPC request handling duration partitioned by namespace and method", | ||
| &["namespace", "function_name"], | ||
| ) | ||
| .unwrap() | ||
| } | ||
|
|
||
| /// Represents the outcome of an RPC request when recording metrics. | ||
| #[derive(Clone, Copy)] | ||
| pub enum RpcOutcome { | ||
| Success, | ||
| Error, | ||
| } | ||
|
|
||
| impl RpcOutcome { | ||
| fn as_label(&self) -> &'static str { | ||
| match self { | ||
| RpcOutcome::Success => "success", | ||
| RpcOutcome::Error => "error", | ||
| } | ||
| } | ||
| } | ||
|
|
||
| pub fn record_rpc_outcome(namespace: &str, function_name: &str, outcome: RpcOutcome) { | ||
| METRICS_RPC_REQUEST_OUTCOMES | ||
| .with_label_values(&[namespace, function_name, outcome.as_label()]) | ||
| .inc(); | ||
| } | ||
|
|
||
| pub fn initialize_rpc_metrics() { | ||
| METRICS_RPC_REQUEST_OUTCOMES.reset(); | ||
| METRICS_RPC_DURATION.reset(); | ||
| } | ||
|
|
||
| /// Records the duration of an async operation in the function profiling histogram. | ||
| /// | ||
| /// This provides a lightweight alternative to the `#[instrument]` attribute when you need | ||
| /// manual control over timing instrumentation, such as in RPC handlers. | ||
| /// | ||
| /// # Parameters | ||
| /// * `namespace` - Category for the metric (e.g., "rpc", "engine", "block_execution") | ||
| /// * `function_name` - Name identifier for the operation being timed | ||
| /// * `future` - The async operation to time | ||
| /// | ||
| /// Use this function when you need to instrument an async operation for duration metrics, | ||
| /// but cannot or do not want to use the `#[instrument]` attribute (for example, in RPC handlers). | ||
| pub async fn record_async_duration<Fut, T>(namespace: &str, function_name: &str, future: Fut) -> T | ||
| where | ||
| Fut: Future<Output = T>, | ||
| { | ||
| let timer = METRICS_RPC_DURATION | ||
| .with_label_values(&[namespace, function_name]) | ||
| .start_timer(); | ||
|
|
||
| let output = future.await; | ||
| timer.observe_duration(); | ||
| output | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.