mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-26 11:07:56 +00:00
Add Prometheus timers to the subsystems (#1923)
* reexport prometheus-super for ease of use of other subsystems * add some prometheus timers for collation generation subsystem * add timing metrics to av-store * add metrics to candidate backing * add timing metric to bitfield signing * add timing metrics to candidate selection * add timing metrics to candidate-validation * add timing metrics to chain-api * add timing metrics to provisioner * add timing metrics to runtime-api * add timing metrics to availability-distribution * add timing metrics to bitfield-distribution * add timing metrics to collator protocol: collator side * add timing metrics to collator protocol: validator side * fix candidate validation test failures * add timing metrics to pov distribution * add timing metrics to statement-distribution * use substrate_prometheus_endpoint prometheus reexport instead of prometheus_super * don't include JOB_DELAY in bitfield-signing metrics * give adder-collator ability to easily export its genesis-state and validation code * wip: adder-collator pushbutton script * don't attempt to register the adder-collator automatically Instead, get these values with ```sh target/release/adder-collator export-genesis-state target/release/adder-collator export-genesis-wasm ``` And then register the parachain on https://polkadot.js.org/apps/?rpc=ws%3A%2F%2F127.0.0.1%3A9944#/explorer To collect prometheus data, after running the script, create `prometheus.yml` per the instructions at https://www.notion.so/paritytechnologies/Setting-up-Prometheus-locally-835cb3a9df7541a781c381006252b5ff and then run: ```sh docker run -v `pwd`/prometheus.yml:/etc/prometheus/prometheus.yml:z --network host prom/prometheus ``` Demonstrates that data makes it across to prometheus, though it is likely to be useful in the future to tweak the buckets. * Update parachain/test-parachains/adder/collator/src/cli.rs Co-authored-by: Andronik Ordian <write@reusable.software> * use the grandpa-pause parameter * skip metrics in tracing instrumentation * remove unnecessary grandpa_pause cli param Co-authored-by: Andronik Ordian <write@reusable.software>
This commit is contained in:
committed by
GitHub
parent
e49989971d
commit
0a5bc82529
@@ -57,12 +57,24 @@ impl Metrics {
|
||||
metrics.collations_sent.inc();
|
||||
}
|
||||
}
|
||||
|
||||
/// Provide a timer for handling `ConnectionRequest` which observes on drop.
|
||||
fn time_handle_connection_request(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
||||
self.0.as_ref().map(|metrics| metrics.handle_connection_request.start_timer())
|
||||
}
|
||||
|
||||
/// Provide a timer for `process_msg` which observes on drop.
|
||||
fn time_process_msg(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
||||
self.0.as_ref().map(|metrics| metrics.process_msg.start_timer())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct MetricsInner {
|
||||
advertisements_made: prometheus::Counter<prometheus::U64>,
|
||||
collations_sent: prometheus::Counter<prometheus::U64>,
|
||||
handle_connection_request: prometheus::Histogram,
|
||||
process_msg: prometheus::Histogram,
|
||||
}
|
||||
|
||||
impl metrics::Metrics for Metrics {
|
||||
@@ -84,6 +96,24 @@ impl metrics::Metrics for Metrics {
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
handle_connection_request: prometheus::register(
|
||||
prometheus::Histogram::with_opts(
|
||||
prometheus::HistogramOpts::new(
|
||||
"parachain_collator_protocol_collator_handle_connection_request",
|
||||
"Time spent within `collator_protocol_collator::handle_connection_request`",
|
||||
)
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
process_msg: prometheus::register(
|
||||
prometheus::Histogram::with_opts(
|
||||
prometheus::HistogramOpts::new(
|
||||
"parachain_collator_protocol_collator_process_msg",
|
||||
"Time spent within `collator_protocol_collator::process_msg`",
|
||||
)
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
};
|
||||
|
||||
Ok(Metrics(Some(metrics)))
|
||||
@@ -377,6 +407,8 @@ where
|
||||
{
|
||||
use CollatorProtocolMessage::*;
|
||||
|
||||
let _timer = state.metrics.time_process_msg();
|
||||
|
||||
match msg {
|
||||
CollateOn(id) => {
|
||||
state.collating_on = Some(id);
|
||||
@@ -662,6 +694,8 @@ where
|
||||
|
||||
loop {
|
||||
if let Some(mut request) = state.last_connection_request.take() {
|
||||
let _timer = state.metrics.time_handle_connection_request();
|
||||
|
||||
while let Poll::Ready(Some((validator_id, peer_id))) = futures::poll!(request.next()) {
|
||||
if let Err(err) = handle_validator_connected(&mut ctx, &mut state, peer_id, validator_id).await {
|
||||
tracing::warn!(
|
||||
|
||||
@@ -63,11 +63,23 @@ impl Metrics {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Provide a timer for `process_msg` which observes on drop.
|
||||
fn time_process_msg(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
||||
self.0.as_ref().map(|metrics| metrics.process_msg.start_timer())
|
||||
}
|
||||
|
||||
/// Provide a timer for `handle_collation_request_result` which observes on drop.
|
||||
fn time_handle_collation_request_result(&self) -> Option<metrics::prometheus::prometheus::HistogramTimer> {
|
||||
self.0.as_ref().map(|metrics| metrics.handle_collation_request_result.start_timer())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct MetricsInner {
|
||||
collation_requests: prometheus::CounterVec<prometheus::U64>,
|
||||
process_msg: prometheus::Histogram,
|
||||
handle_collation_request_result: prometheus::Histogram,
|
||||
}
|
||||
|
||||
impl metrics::Metrics for Metrics {
|
||||
@@ -84,7 +96,25 @@ impl metrics::Metrics for Metrics {
|
||||
&["success"],
|
||||
)?,
|
||||
registry,
|
||||
)?
|
||||
)?,
|
||||
process_msg: prometheus::register(
|
||||
prometheus::Histogram::with_opts(
|
||||
prometheus::HistogramOpts::new(
|
||||
"parachain_collator_protocol_validator_process_msg",
|
||||
"Time spent within `collator_protocol_validator::process_msg`",
|
||||
)
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
handle_collation_request_result: prometheus::register(
|
||||
prometheus::Histogram::with_opts(
|
||||
prometheus::HistogramOpts::new(
|
||||
"parachain_collator_protocol_validator_handle_collation_request_result",
|
||||
"Time spent within `collator_protocol_validator::handle_collation_request_result`",
|
||||
)
|
||||
)?,
|
||||
registry,
|
||||
)?,
|
||||
};
|
||||
|
||||
Ok(Metrics(Some(metrics)))
|
||||
@@ -628,6 +658,8 @@ where
|
||||
{
|
||||
use CollatorProtocolMessage::*;
|
||||
|
||||
let _timer = state.metrics.time_process_msg();
|
||||
|
||||
match msg {
|
||||
CollateOn(id) => {
|
||||
tracing::warn!(
|
||||
@@ -703,6 +735,8 @@ where
|
||||
}
|
||||
|
||||
while let Poll::Ready(Some(request)) = futures::poll!(state.requests_in_progress.next()) {
|
||||
let _timer = state.metrics.time_handle_collation_request_result();
|
||||
|
||||
// Request has timed out, we need to penalize the collator and re-send the request
|
||||
// if the chain has not moved on yet.
|
||||
match request {
|
||||
|
||||
Reference in New Issue
Block a user