mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 13:27:57 +00:00
002d9260f9
**Update:** Pushed additional changes based on the review comments. **This pull request fixes various spelling mistakes in this repository.** Most of the changes are contained in the first **3** commits: - `Fix spelling mistakes in comments and docs` - `Fix spelling mistakes in test names` - `Fix spelling mistakes in error messages, panic messages, logs and tracing` Other source code spelling mistakes are separated into individual commits for easier reviewing: - `Fix the spelling of 'authority'` - `Fix the spelling of 'REASONABLE_HEADERS_IN_JUSTIFICATION_ANCESTRY'` - `Fix the spelling of 'prev_enqueud_messages'` - `Fix the spelling of 'endpoint'` - `Fix the spelling of 'children'` - `Fix the spelling of 'PenpalSiblingSovereignAccount'` - `Fix the spelling of 'PenpalSudoAccount'` - `Fix the spelling of 'insufficient'` - `Fix the spelling of 'PalletXcmExtrinsicsBenchmark'` - `Fix the spelling of 'subtracted'` - `Fix the spelling of 'CandidatePendingAvailability'` - `Fix the spelling of 'exclusive'` - `Fix the spelling of 'until'` - `Fix the spelling of 'discriminator'` - `Fix the spelling of 'nonexistent'` - `Fix the spelling of 'subsystem'` - `Fix the spelling of 'indices'` - `Fix the spelling of 'committed'` - `Fix the spelling of 'topology'` - `Fix the spelling of 'response'` - `Fix the spelling of 'beneficiary'` - `Fix the spelling of 'formatted'` - `Fix the spelling of 'UNKNOWN_PROOF_REQUEST'` - `Fix the spelling of 'succeeded'` - `Fix the spelling of 'reopened'` - `Fix the spelling of 'proposer'` - `Fix the spelling of 'InstantiationNonce'` - `Fix the spelling of 'depositor'` - `Fix the spelling of 'expiration'` - `Fix the spelling of 'phantom'` - `Fix the spelling of 'AggregatedKeyValue'` - `Fix the spelling of 'randomness'` - `Fix the spelling of 'defendant'` - `Fix the spelling of 'AquaticMammal'` - `Fix the spelling of 'transactions'` - `Fix the spelling of 'PassingTracingSubscriber'` - `Fix the spelling of 'TxSignaturePayload'` - `Fix the spelling of 'versioning'` - `Fix the spelling of 'descendant'` - `Fix the spelling of 'overridden'` - `Fix the spelling of 'network'` Let me know if this structure is adequate. **Note:** The usage of the words `Merkle`, `Merkelize`, `Merklization`, `Merkelization`, `Merkleization`, is somewhat inconsistent but I left it as it is. ~~**Note:** In some places the term `Receival` is used to refer to message reception, IMO `Reception` is the correct word here, but I left it as it is.~~ ~~**Note:** In some places the term `Overlayed` is used instead of the more acceptable version `Overlaid` but I also left it as it is.~~ ~~**Note:** In some places the term `Applyable` is used instead of the correct version `Applicable` but I also left it as it is.~~ **Note:** Some usage of British vs American english e.g. `judgement` vs `judgment`, `initialise` vs `initialize`, `optimise` vs `optimize` etc. are both present in different places, but I suppose that's understandable given the number of contributors. ~~**Note:** There is a spelling mistake in `.github/CODEOWNERS` but it triggers errors in CI when I make changes to it, so I left it as it is.~~
244 lines
7.9 KiB
Rust
244 lines
7.9 KiB
Rust
// Copyright (C) Parity Technologies (UK) Ltd.
|
|
// This file is part of Polkadot.
|
|
|
|
// Polkadot 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.
|
|
|
|
// Polkadot 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 Polkadot. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
use polkadot_node_subsystem_util::metrics::{
|
|
self,
|
|
prometheus::{self, Counter, CounterVec, Histogram, Opts, PrometheusError, Registry, U64},
|
|
};
|
|
|
|
/// Availability Distribution metrics.
|
|
#[derive(Clone, Default)]
|
|
pub struct Metrics(Option<MetricsInner>);
|
|
|
|
#[derive(Clone)]
|
|
struct MetricsInner {
|
|
/// Number of sent chunk requests.
|
|
///
|
|
/// Gets incremented on each sent chunk requests.
|
|
chunk_requests_issued: Counter<U64>,
|
|
/// Total number of bytes recovered
|
|
///
|
|
/// Gets incremented on each successful recovery
|
|
recovered_bytes_total: Counter<U64>,
|
|
/// A counter for finished chunk requests.
|
|
///
|
|
/// Split by result:
|
|
/// - `no_such_chunk` ... peer did not have the requested chunk
|
|
/// - `timeout` ... request timed out.
|
|
/// - `network_error` ... Some networking issue except timeout
|
|
/// - `invalid` ... Chunk was received, but not valid.
|
|
/// - `success`
|
|
chunk_requests_finished: CounterVec<U64>,
|
|
|
|
/// The duration of request to response.
|
|
time_chunk_request: Histogram,
|
|
|
|
/// The duration between the pure recovery and verification.
|
|
time_erasure_recovery: Histogram,
|
|
|
|
/// How much time it takes to re-encode the data into erasure chunks in order to verify
|
|
/// the root hash of the provided Merkle tree. See `reconstructed_data_matches_root`.
|
|
time_reencode_chunks: Histogram,
|
|
|
|
/// Time of a full recovery, including erasure decoding or until we gave
|
|
/// up.
|
|
time_full_recovery: Histogram,
|
|
|
|
/// Number of full recoveries that have been finished one way or the other.
|
|
full_recoveries_finished: CounterVec<U64>,
|
|
|
|
/// Number of full recoveries that have been started on this subsystem.
|
|
///
|
|
/// Note: Those are only recoveries which could not get served locally already - so in other
|
|
/// words: Only real recoveries.
|
|
full_recoveries_started: Counter<U64>,
|
|
}
|
|
|
|
impl Metrics {
|
|
/// Create new dummy metrics, not reporting anything.
|
|
pub fn new_dummy() -> Self {
|
|
Metrics(None)
|
|
}
|
|
|
|
/// Increment counter on fetched labels.
|
|
pub fn on_chunk_request_issued(&self) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.chunk_requests_issued.inc()
|
|
}
|
|
}
|
|
|
|
/// A chunk request timed out.
|
|
pub fn on_chunk_request_timeout(&self) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.chunk_requests_finished.with_label_values(&["timeout"]).inc()
|
|
}
|
|
}
|
|
|
|
/// A chunk request failed because validator did not have its chunk.
|
|
pub fn on_chunk_request_no_such_chunk(&self) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.chunk_requests_finished.with_label_values(&["no_such_chunk"]).inc()
|
|
}
|
|
}
|
|
|
|
/// A chunk request failed for some non timeout related network error.
|
|
pub fn on_chunk_request_error(&self) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.chunk_requests_finished.with_label_values(&["error"]).inc()
|
|
}
|
|
}
|
|
|
|
/// A chunk request succeeded, but was not valid.
|
|
pub fn on_chunk_request_invalid(&self) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.chunk_requests_finished.with_label_values(&["invalid"]).inc()
|
|
}
|
|
}
|
|
|
|
/// A chunk request succeeded.
|
|
pub fn on_chunk_request_succeeded(&self) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.chunk_requests_finished.with_label_values(&["success"]).inc()
|
|
}
|
|
}
|
|
|
|
/// Get a timer to time request/response duration.
|
|
pub fn time_chunk_request(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
|
self.0.as_ref().map(|metrics| metrics.time_chunk_request.start_timer())
|
|
}
|
|
|
|
/// Get a timer to time erasure code recover.
|
|
pub fn time_erasure_recovery(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
|
self.0.as_ref().map(|metrics| metrics.time_erasure_recovery.start_timer())
|
|
}
|
|
|
|
/// Get a timer to time chunk encoding.
|
|
pub fn time_reencode_chunks(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
|
self.0.as_ref().map(|metrics| metrics.time_reencode_chunks.start_timer())
|
|
}
|
|
|
|
/// Get a timer to measure the time of the complete recovery process.
|
|
pub fn time_full_recovery(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
|
self.0.as_ref().map(|metrics| metrics.time_full_recovery.start_timer())
|
|
}
|
|
|
|
/// A full recovery succeeded.
|
|
pub fn on_recovery_succeeded(&self, bytes: usize) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.full_recoveries_finished.with_label_values(&["success"]).inc();
|
|
metrics.recovered_bytes_total.inc_by(bytes as u64)
|
|
}
|
|
}
|
|
|
|
/// A full recovery failed (data not available).
|
|
pub fn on_recovery_failed(&self) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.full_recoveries_finished.with_label_values(&["failure"]).inc()
|
|
}
|
|
}
|
|
|
|
/// A full recovery failed (data was recovered, but invalid).
|
|
pub fn on_recovery_invalid(&self) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.full_recoveries_finished.with_label_values(&["invalid"]).inc()
|
|
}
|
|
}
|
|
|
|
/// A recover was started.
|
|
pub fn on_recovery_started(&self) {
|
|
if let Some(metrics) = &self.0 {
|
|
metrics.full_recoveries_started.inc()
|
|
}
|
|
}
|
|
}
|
|
|
|
impl metrics::Metrics for Metrics {
|
|
fn try_register(registry: &Registry) -> Result<Self, PrometheusError> {
|
|
let metrics = MetricsInner {
|
|
chunk_requests_issued: prometheus::register(
|
|
Counter::new(
|
|
"polkadot_parachain_availability_recovery_chunk_requests_issued",
|
|
"Total number of issued chunk requests.",
|
|
)?,
|
|
registry,
|
|
)?,
|
|
recovered_bytes_total: prometheus::register(
|
|
Counter::new(
|
|
"polkadot_parachain_availability_recovery_bytes_total",
|
|
"Total number of bytes recovered",
|
|
)?,
|
|
registry,
|
|
)?,
|
|
chunk_requests_finished: prometheus::register(
|
|
CounterVec::new(
|
|
Opts::new(
|
|
"polkadot_parachain_availability_recovery_chunk_requests_finished",
|
|
"Total number of chunk requests finished.",
|
|
),
|
|
&["result"],
|
|
)?,
|
|
registry,
|
|
)?,
|
|
time_chunk_request: prometheus::register(
|
|
prometheus::Histogram::with_opts(prometheus::HistogramOpts::new(
|
|
"polkadot_parachain_availability_recovery_time_chunk_request",
|
|
"Time spent waiting for a response to a chunk request",
|
|
))?,
|
|
registry,
|
|
)?,
|
|
time_erasure_recovery: prometheus::register(
|
|
prometheus::Histogram::with_opts(prometheus::HistogramOpts::new(
|
|
"polkadot_parachain_availability_recovery_time_erasure_recovery",
|
|
"Time spent to recover the erasure code and verify the merkle root by re-encoding as erasure chunks",
|
|
))?,
|
|
registry,
|
|
)?,
|
|
time_reencode_chunks: prometheus::register(
|
|
prometheus::Histogram::with_opts(prometheus::HistogramOpts::new(
|
|
"polkadot_parachain_availability_reencode_chunks",
|
|
"Time spent re-encoding the data as erasure chunks",
|
|
))?,
|
|
registry,
|
|
)?,
|
|
time_full_recovery: prometheus::register(
|
|
prometheus::Histogram::with_opts(prometheus::HistogramOpts::new(
|
|
"polkadot_parachain_availability_recovery_time_total",
|
|
"Time a full recovery process took, either until failure or successful erasure decoding.",
|
|
))?,
|
|
registry,
|
|
)?,
|
|
full_recoveries_finished: prometheus::register(
|
|
CounterVec::new(
|
|
Opts::new(
|
|
"polkadot_parachain_availability_recovery_recoveries_finished",
|
|
"Total number of recoveries that finished.",
|
|
),
|
|
&["result"],
|
|
)?,
|
|
registry,
|
|
)?,
|
|
full_recoveries_started: prometheus::register(
|
|
Counter::new(
|
|
"polkadot_parachain_availability_recovery_recoveries_started",
|
|
"Total number of started recoveries.",
|
|
)?,
|
|
registry,
|
|
)?,
|
|
};
|
|
Ok(Metrics(Some(metrics)))
|
|
}
|
|
}
|