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:
Peter Goodspeed-Niklaus
2020-11-20 15:04:51 +01:00
committed by GitHub
parent e49989971d
commit 0a5bc82529
23 changed files with 1199 additions and 87 deletions
@@ -16,71 +16,88 @@
//! Collator for the adder test parachain.
use sc_cli::{Result, Role, SubstrateCli};
use polkadot_cli::Cli;
use polkadot_node_subsystem::messages::{CollatorProtocolMessage, CollationGenerationMessage};
use polkadot_node_primitives::CollationGenerationConfig;
use polkadot_node_subsystem::messages::{CollationGenerationMessage, CollatorProtocolMessage};
use polkadot_primitives::v1::Id as ParaId;
use test_parachain_adder_collator::Collator;
use sc_cli::{Result, Role, SubstrateCli};
use sp_core::hexdisplay::HexDisplay;
use std::time::Duration;
use test_parachain_adder_collator::Collator;
const PARA_ID: ParaId = ParaId::new(100);
mod cli;
use cli::Cli;
fn main() -> Result<()> {
let cli = Cli::from_args();
if cli.subcommand.is_some() {
return Err("Subcommands are not supported".into())
}
match cli.subcommand {
Some(cli::Subcommand::ExportGenesisState(_params)) => {
let collator = Collator::new();
println!("0x{:?}", HexDisplay::from(&collator.genesis_head()));
let runner = cli.create_runner(&cli.run.base)?;
runner.run_node_until_exit(|config| async move {
let role = config.role.clone();
match role {
Role::Light => Err("Light client not supported".into()),
_ => {
let collator = Collator::new();
let full_node = polkadot_service::build_full(
config,
polkadot_service::IsCollator::Yes(collator.collator_id()),
None,
Some(sc_authority_discovery::WorkerConfig {
query_interval: Duration::from_secs(1),
query_start_delay: Duration::from_secs(0),
..Default::default()
}),
)?;
let mut overseer_handler = full_node.overseer_handler
.expect("Overseer handler should be initialized for collators");
let genesis_head_hex = format!("0x{:?}", HexDisplay::from(&collator.genesis_head()));
let validation_code_hex = format!("0x{:?}", HexDisplay::from(&collator.validation_code()));
log::info!("Running adder collator for parachain id: {}", PARA_ID);
log::info!("Genesis state: {}", genesis_head_hex);
log::info!("Validation code: {}", validation_code_hex);
let config = CollationGenerationConfig {
key: collator.collator_key(),
collator: collator.create_collation_function(),
para_id: PARA_ID,
};
overseer_handler
.send_msg(CollationGenerationMessage::Initialize(config))
.await
.expect("Registers collator");
overseer_handler
.send_msg(CollatorProtocolMessage::CollateOn(PARA_ID))
.await
.expect("Collates on");
Ok(full_node.task_manager)
},
Ok(())
}
})
Some(cli::Subcommand::ExportGenesisWasm(_params)) => {
let collator = Collator::new();
println!("0x{:?}", HexDisplay::from(&collator.validation_code()));
Ok(())
}
None => {
let runner = cli.create_runner(&cli.run.base)?;
runner.run_node_until_exit(|config| async move {
let role = config.role.clone();
match role {
Role::Light => Err("Light client not supported".into()),
_ => {
let collator = Collator::new();
let full_node = polkadot_service::build_full(
config,
polkadot_service::IsCollator::Yes(collator.collator_id()),
None,
Some(sc_authority_discovery::WorkerConfig {
query_interval: Duration::from_secs(1),
query_start_delay: Duration::from_secs(0),
..Default::default()
}),
)?;
let mut overseer_handler = full_node
.overseer_handler
.expect("Overseer handler should be initialized for collators");
let genesis_head_hex =
format!("0x{:?}", HexDisplay::from(&collator.genesis_head()));
let validation_code_hex =
format!("0x{:?}", HexDisplay::from(&collator.validation_code()));
log::info!("Running adder collator for parachain id: {}", PARA_ID);
log::info!("Genesis state: {}", genesis_head_hex);
log::info!("Validation code: {}", validation_code_hex);
let config = CollationGenerationConfig {
key: collator.collator_key(),
collator: collator.create_collation_function(),
para_id: PARA_ID,
};
overseer_handler
.send_msg(CollationGenerationMessage::Initialize(config))
.await
.expect("Registers collator");
overseer_handler
.send_msg(CollatorProtocolMessage::CollateOn(PARA_ID))
.await
.expect("Collates on");
Ok(full_node.task_manager)
}
}
})
}
}
}