-
Notifications
You must be signed in to change notification settings - Fork 1.2k
rpc-v2/metrics: Align RPC metrics with tx pool metrics #10105
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
base: master
Are you sure you want to change the base?
Changes from all commits
746d1b0
ffd2a23
4ca4c0d
4abaf67
961f8e3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| title: 'rpc-v2/metrics: Align RPC metrics with tx pool metrics' | ||
| doc: | ||
| - audience: Node Dev | ||
| description: |- | ||
| This PR syncs the tx pool metrics with the RPC layer metrics. | ||
|
|
||
| The TX Pool metrics are re-exported under a `histogram` module, such that the RPC layer can reuse the same settings. This ensures that the RPC will be in sync with the Tx Pool metrics for the reliability dashboards. | ||
|
|
||
| Closes: https://github.com/paritytech/polkadot-sdk/issues/10067 | ||
| crates: | ||
| - name: sc-rpc-spec-v2 | ||
| bump: patch | ||
| - name: sc-transaction-pool | ||
| bump: patch |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,97 @@ | ||||||
| // This file is part of Substrate. | ||||||
|
|
||||||
| // Copyright (C) Parity Technologies (UK) Ltd. | ||||||
| // SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0 | ||||||
|
|
||||||
| // This program is free software: you can redistribute it and/or modify | ||||||
| // it under the terms of the GNU General Public License as published by | ||||||
| // the Free Software Foundation, either version 3 of the License, or | ||||||
| // (at your option) any later version. | ||||||
|
|
||||||
| // This program is distributed in the hope that it will be useful, | ||||||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||
| // GNU General Public License for more details. | ||||||
|
|
||||||
| // You should have received a copy of the GNU General Public License | ||||||
| // along with this program. If not, see <https://www.gnu.org/licenses/>. | ||||||
|
|
||||||
| //! Transaction metrics for various transaction states. | ||||||
| //! | ||||||
| //! The histograms are shared between the transaction pool and the RPC layer. | ||||||
| //! | ||||||
| //! # Note | ||||||
| //! | ||||||
| //! The RPC layer will utilize a subset of these metrics for now, since the | ||||||
| //! RPC emitted events do not have a direct mapping to all transaction pool events. | ||||||
| //! | ||||||
| //! Changing these metrics will impact the RPC layer as well. | ||||||
|
|
||||||
| use prometheus_endpoint::{ | ||||||
| exponential_buckets, histogram_opts, linear_buckets, Histogram, PrometheusError, | ||||||
| }; | ||||||
|
|
||||||
| /// Histogram of timings for reporting `Ready`/`Future` events. | ||||||
| pub fn ready_future(name: &'static str, label: &'static str) -> Result<Histogram, PrometheusError> { | ||||||
| Histogram::with_opts(histogram_opts!(name, label, exponential_buckets(0.01, 2.0, 16).unwrap())) | ||||||
| } | ||||||
|
|
||||||
| /// Histogram of timings for reporting `Broadcast` event. | ||||||
| pub fn broadcast(name: &'static str, label: &'static str) -> Result<Histogram, PrometheusError> { | ||||||
| Histogram::with_opts(histogram_opts!(name, label, linear_buckets(0.01, 0.25, 16).unwrap())) | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this mean the first bucket is
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would may be even write it as
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And, honestly, I don't know how the histograms are rendered in the UI, and if it makes sense visualization-wise.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Im not entirely familiar with the reliability buckets 🤔 Maybe @michalkucharczyk or @olliecorbisiero could provide better answers There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @dmitry-markin @lexnv do the buckets I outlined in issue #10067 help clear things up?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would leave it as is. |
||||||
| } | ||||||
|
|
||||||
| /// Histogram of timings for reporting `InBlock` event. | ||||||
| pub fn in_block(name: &'static str, label: &'static str) -> Result<Histogram, PrometheusError> { | ||||||
| Histogram::with_opts( | ||||||
| histogram_opts!(name, label).buckets( | ||||||
| [ | ||||||
| linear_buckets(0.0, 3.0, 20).unwrap(), | ||||||
| // requested in #9158 | ||||||
| vec![60.0, 75.0, 90.0, 120.0, 180.0], | ||||||
| ] | ||||||
| .concat(), | ||||||
| ), | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| /// Histogram of timings for reporting `Retracted` event. | ||||||
| pub fn retracted(name: &'static str, label: &'static str) -> Result<Histogram, PrometheusError> { | ||||||
| Histogram::with_opts(histogram_opts!(name, label, linear_buckets(0.0, 3.0, 20).unwrap())) | ||||||
| } | ||||||
|
|
||||||
| /// Histogram of timings for reporting `FinalityTimeout` event. | ||||||
| pub fn finalized_timeout( | ||||||
| name: &'static str, | ||||||
| label: &'static str, | ||||||
| ) -> Result<Histogram, PrometheusError> { | ||||||
| Histogram::with_opts(histogram_opts!(name, label, linear_buckets(0.0, 40.0, 20).unwrap())) | ||||||
| } | ||||||
|
|
||||||
| /// Histogram of timings for reporting `Finalized` event. | ||||||
| pub fn finalized(name: &'static str, label: &'static str) -> Result<Histogram, PrometheusError> { | ||||||
| Histogram::with_opts( | ||||||
| histogram_opts!(name, label).buckets( | ||||||
| [ | ||||||
| // requested in #9158 | ||||||
| linear_buckets(0.0, 5.0, 8).unwrap(), | ||||||
| linear_buckets(40.0, 40.0, 19).unwrap(), | ||||||
| ] | ||||||
| .concat(), | ||||||
| ), | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| /// Histogram of timings for reporting `Invalid` / `Dropped` / `Usurped` events. | ||||||
| pub fn invalid(name: &'static str, label: &'static str) -> Result<Histogram, PrometheusError> { | ||||||
| Histogram::with_opts( | ||||||
| histogram_opts!(name, label).buckets( | ||||||
| [ | ||||||
| linear_buckets(0.0, 3.0, 20).unwrap(), | ||||||
| // requested in PR 9158 | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| vec![60.0, 75.0, 90.0, 120.0, 180.0], | ||||||
| ] | ||||||
| .concat(), | ||||||
| ), | ||||||
| ) | ||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe
metric_buckets.rs(orshared_metric_buckets.rs) would be a better name for this file?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
or
timing_metric_buckets.rs?