From a522a58b61964b08b8aa90d5cd1e65933f4d59fc Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Tue, 25 Feb 2020 11:59:48 +0100 Subject: [PATCH 1/6] Add a few things --- Cargo.lock | 1 + client/network/Cargo.toml | 1 + client/network/src/config.rs | 4 ++++ client/network/src/error.rs | 3 +++ client/network/src/service.rs | 41 +++++++++++++++++++++++++++++++--- client/network/test/src/lib.rs | 6 +++-- client/service/src/builder.rs | 31 ++++++++++++++----------- 7 files changed, 69 insertions(+), 18 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 48b14599b1ca9..dd241a41705c0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6233,6 +6233,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.10.0", "pin-project", + "prometheus-exporter", "prost", "prost-build", "quickcheck", diff --git a/client/network/Cargo.toml b/client/network/Cargo.toml index 48a6fee638a87..c25ef0284f8fd 100644 --- a/client/network/Cargo.toml +++ b/client/network/Cargo.toml @@ -53,6 +53,7 @@ sp-keyring = { version = "2.0.0-dev", optional = true, path = "../../primitives/ sp-runtime = { version = "2.0.0-dev", path = "../../primitives/runtime" } substrate-test-client = { version = "2.0.0-dev", optional = true, path = "../../test-utils/client" } substrate-test-runtime-client = { version = "2.0.0-dev", optional = true, path = "../../test-utils/runtime/client" } +prometheus-exporter = { version = "0.8.0-dev", path = "../../utils/prometheus" } thiserror = "1" unsigned-varint = { version = "0.3.1", features = ["futures", "futures-codec"] } void = "1.0.2" diff --git a/client/network/src/config.rs b/client/network/src/config.rs index f5cad5977fc47..a142d1eb41f89 100644 --- a/client/network/src/config.rs +++ b/client/network/src/config.rs @@ -41,6 +41,7 @@ use core::{fmt, iter}; use std::{future::Future, pin::Pin}; use std::{error::Error, fs, io::{self, Write}, net::Ipv4Addr, path::{Path, PathBuf}, sync::Arc}; use zeroize::Zeroize; +use prometheus_exporter::Registry; /// Network initialization parameters. pub struct Params { @@ -90,6 +91,9 @@ pub struct Params { /// Type to check incoming block announcements. pub block_announce_validator: Box + Send>, + + /// Registry for recording prometheus metrics to. + pub metrics_registry: Option, } bitflags! { diff --git a/client/network/src/error.rs b/client/network/src/error.rs index ba5d5c2d0d2b5..a34a2bd691f99 100644 --- a/client/network/src/error.rs +++ b/client/network/src/error.rs @@ -45,6 +45,8 @@ pub enum Error { /// The second peer id that was found for the bootnode. second_id: PeerId, }, + /// Prometheus metrics error. + Prometheus(prometheus_exporter::PrometheusError) } // Make `Debug` use the `Display` implementation. @@ -60,6 +62,7 @@ impl std::error::Error for Error { Error::Io(ref err) => Some(err), Error::Client(ref err) => Some(err), Error::DuplicateBootnode { .. } => None, + Error::Prometheus(ref err) => Some(err), } } } diff --git a/client/network/src/service.rs b/client/network/src/service.rs index 288289d95c81e..f47a97c557313 100644 --- a/client/network/src/service.rs +++ b/client/network/src/service.rs @@ -39,6 +39,7 @@ use libp2p::swarm::{NetworkBehaviour, SwarmBuilder, SwarmEvent}; use parking_lot::Mutex; use sc_peerset::PeersetHandle; use sp_runtime::{traits::{Block as BlockT, NumberFor}, ConsensusEngineId}; +use prometheus_exporter::{Registry, Gauge, U64, register, PrometheusError}; use crate::{behaviour::{Behaviour, BehaviourOut}, config::{parse_str_addr, parse_addr}}; use crate::{transport, config::NonReservedPeerMode, ReputationChange}; @@ -294,6 +295,10 @@ impl NetworkWorker { from_worker, light_client_rqs: params.on_demand.and_then(|od| od.extract_receiver()), event_streams: Vec::new(), + metrics: match params.metrics_registry { + Some(registry) => Some(Metrics::register(®istry)?), + None => None + } }) } @@ -727,6 +732,26 @@ pub struct NetworkWorker { light_client_rqs: Option>>, /// Senders for events that happen on the network. event_streams: Vec>, + /// Prometheus network metrics. + metrics: Option +} + +struct Metrics { + is_major_syncing: Gauge, + peers_count: Gauge, +} + +impl Metrics { + fn register(registry: &Registry) -> Result { + Ok(Self { + is_major_syncing: register(Gauge::new( + "is_major_syncing", "Whether the node is performing a major sync or not.", + )?, registry)?, + peers_count: register(Gauge::new( + "peers_count", "Number of network gossip peers", + )?, registry)?, + }) + } } impl Future for NetworkWorker { @@ -818,16 +843,26 @@ impl Future for NetworkWorker { }; } + let num_connected_peers = this.network_service.user_protocol_mut().num_connected_peers(); + // Update the variables shared with the `NetworkService`. - this.num_connected.store(this.network_service.user_protocol_mut().num_connected_peers(), Ordering::Relaxed); + this.num_connected.store(num_connected_peers, Ordering::Relaxed); { let external_addresses = Swarm::::external_addresses(&this.network_service).cloned().collect(); *this.external_addresses.lock() = external_addresses; } - this.is_major_syncing.store(match this.network_service.user_protocol_mut().sync_state() { + + let is_major_syncing = match this.network_service.user_protocol_mut().sync_state() { SyncState::Idle => false, SyncState::Downloading => true, - }, Ordering::Relaxed); + }; + + this.is_major_syncing.store(is_major_syncing, Ordering::Relaxed); + + if let Some(metrics) = this.metrics.as_ref() { + metrics.is_major_syncing.set(is_major_syncing as u64); + metrics.peers_count.set(num_connected_peers as u64); + } Poll::Pending } diff --git a/client/network/test/src/lib.rs b/client/network/test/src/lib.rs index 982e2ff512396..13f18ba878ca7 100644 --- a/client/network/test/src/lib.rs +++ b/client/network/test/src/lib.rs @@ -622,7 +622,8 @@ pub trait TestNetFactory: Sized { transaction_pool: Arc::new(EmptyTransactionPool), protocol_id: ProtocolId::from(&b"test-protocol-name"[..]), import_queue, - block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())) + block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())), + metrics_registry: None, }).unwrap(); self.mut_peers(|peers| { @@ -697,7 +698,8 @@ pub trait TestNetFactory: Sized { transaction_pool: Arc::new(EmptyTransactionPool), protocol_id: ProtocolId::from(&b"test-protocol-name"[..]), import_queue, - block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())) + block_announce_validator: Box::new(DefaultBlockAnnounceValidator::new(client.clone())), + metrics_registry: None, }).unwrap(); self.mut_peers(|peers| { diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 7159e532c4259..8c5b94a25e3e1 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -57,11 +57,11 @@ use prometheus_exporter::{register, Gauge, U64, F64, Registry, PrometheusError, struct ServiceMetrics { block_height_number: GaugeVec, - peers_count: Gauge, ready_transactions_number: Gauge, memory_usage_bytes: Gauge, cpu_usage_percentage: Gauge, network_per_sec_bytes: GaugeVec, + node_roles: Gauge, } impl ServiceMetrics { @@ -71,9 +71,6 @@ impl ServiceMetrics { Opts::new("block_height_number", "Height of the chain"), &["status"] )?, registry)?, - peers_count: register(Gauge::new( - "peers_count", "Number of network gossip peers", - )?, registry)?, ready_transactions_number: register(Gauge::new( "ready_transactions_number", "Number of transactions in the ready queue", )?, registry)?, @@ -87,6 +84,10 @@ impl ServiceMetrics { Opts::new("network_per_sec_bytes", "Networking bytes per second"), &["direction"] )?, registry)?, + node_roles: register(Gauge::new( + "node_roles", "The roles the node is running as", + )?, registry)?, + }) } } @@ -887,6 +888,14 @@ ServiceBuilder< let block_announce_validator = Box::new(sp_consensus::block_validation::DefaultBlockAnnounceValidator::new(client.clone())); + let prometheus_registry_and_port = match config.prometheus_port { + Some(port) => match prometheus_registry { + Some(registry) => Some((registry, port)), + None => Some((Registry::new_custom(Some("substrate".into()), None)?, port)) + }, + None => None + }; + let network_params = sc_network::config::Params { roles: config.roles, executor: { @@ -906,6 +915,7 @@ ServiceBuilder< import_queue, protocol_id, block_announce_validator, + metrics_registry: prometheus_registry_and_port.as_ref().map(|(r, _)| r.clone()) }; let has_bootnodes = !network_params.network_config.boot_nodes.is_empty(); @@ -1020,15 +1030,12 @@ ServiceBuilder< )); } - // Prometheus exporter and metrics - let metrics = if let Some(port) = config.prometheus_port { - let registry = match prometheus_registry { - Some(registry) => registry, - None => Registry::new_custom(Some("substrate".into()), None)? - }; - + // Prometheus metrics + let metrics = if let Some((registry, port)) = prometheus_registry_and_port { let metrics = ServiceMetrics::register(®istry)?; + metrics.node_roles.set(u64::from(config.roles.bits())); + let future = select( prometheus_exporter::init_prometheus(port, registry).boxed(), exit.clone() @@ -1043,7 +1050,6 @@ ServiceBuilder< } else { None }; - // Periodically notify the telemetry. let transaction_pool_ = transaction_pool.clone(); let client_ = client.clone(); @@ -1094,7 +1100,6 @@ ServiceBuilder< metrics.memory_usage_bytes.set(memory); metrics.cpu_usage_percentage.set(f64::from(cpu_usage)); metrics.ready_transactions_number.set(txpool_status.ready as u64); - metrics.peers_count.set(num_peers as u64); metrics.network_per_sec_bytes.with_label_values(&["download"]).set(net_status.average_download_per_sec); metrics.network_per_sec_bytes.with_label_values(&["upload"]).set(net_status.average_upload_per_sec); From 790ad910c2c14e62324150b83d322e6e3ea01072 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Tue, 25 Feb 2020 18:36:04 +0100 Subject: [PATCH 2/6] Add finality_grandpa_round --- Cargo.lock | 1 + bin/node-template/node/src/service.rs | 1 + bin/node/cli/src/service.rs | 1 + client/finality-grandpa/Cargo.toml | 1 + client/finality-grandpa/src/environment.rs | 30 ++++++++++++++++++++++ client/finality-grandpa/src/lib.rs | 9 ++++++- client/service/Cargo.toml | 2 +- client/service/src/builder.rs | 3 ++- client/service/src/lib.rs | 8 ++++++ 9 files changed, 53 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dd241a41705c0..60a06784ebd4a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6150,6 +6150,7 @@ dependencies = [ "parity-scale-codec", "parking_lot 0.10.0", "pin-project", + "prometheus-exporter", "rand 0.7.3", "sc-client", "sc-client-api", diff --git a/bin/node-template/node/src/service.rs b/bin/node-template/node/src/service.rs index 5b64984c47c99..3eb4e092f4f47 100644 --- a/bin/node-template/node/src/service.rs +++ b/bin/node-template/node/src/service.rs @@ -160,6 +160,7 @@ pub fn new_full(config: Configuration) on_exit: service.on_exit(), telemetry_on_connect: Some(service.telemetry_on_connect_stream()), voting_rule: grandpa::VotingRulesBuilder::default().build(), + prometheus_registry: service.prometheus_registry() }; // the GRANDPA voter task is considered infallible, i.e. diff --git a/bin/node/cli/src/service.rs b/bin/node/cli/src/service.rs index 70dd0521dece3..924988a7ecfd0 100644 --- a/bin/node/cli/src/service.rs +++ b/bin/node/cli/src/service.rs @@ -228,6 +228,7 @@ macro_rules! new_full { on_exit: service.on_exit(), telemetry_on_connect: Some(service.telemetry_on_connect_stream()), voting_rule: grandpa::VotingRulesBuilder::default().build(), + prometheus_registry: service.prometheus_registry(), }; // the GRANDPA voter task is considered infallible, i.e. diff --git a/client/finality-grandpa/Cargo.toml b/client/finality-grandpa/Cargo.toml index 46dd444cdfc13..5d4f761b3b5e5 100644 --- a/client/finality-grandpa/Cargo.toml +++ b/client/finality-grandpa/Cargo.toml @@ -31,6 +31,7 @@ sc-network = { version = "0.8.0-dev", path = "../network" } sc-network-gossip = { version = "0.8.0-dev", path = "../network-gossip" } sp-finality-tracker = { version = "2.0.0-dev", path = "../../primitives/finality-tracker" } sp-finality-grandpa = { version = "2.0.0-dev", path = "../../primitives/finality-grandpa" } +prometheus-exporter = { path = "../../utils/prometheus", version = "0.8.0-dev" } finality-grandpa = { version = "0.11.1", features = ["derive-codec"] } pin-project = "0.4.6" diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index fd88113776c9c..3ec370c736a7b 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -62,6 +62,7 @@ use crate::justification::GrandpaJustification; use crate::until_imported::UntilVoteTargetImported; use crate::voting_rule::VotingRule; use sp_finality_grandpa::{AuthorityId, AuthoritySignature, SetId, RoundNumber}; +use prometheus_exporter::{Gauge, U64, register, PrometheusError}; type HistoricalVotes = finality_grandpa::HistoricalVotes< ::Hash, @@ -376,6 +377,23 @@ impl SharedVoterSetState { } } +/// Prometheus metrics for GRANDPA. +#[derive(Clone)] +pub(crate) struct Metrics { + finality_grandpa_round: Gauge, +} + +impl Metrics { + pub(crate) fn register(registry: &prometheus_exporter::Registry) -> Result { + Ok(Self { + finality_grandpa_round: register(Gauge::new( + "finality_grandpa_round", "Highest completed GRANDPA round.", + )?, registry)?, + }) + } +} + + /// The environment we run GRANDPA in. pub(crate) struct Environment, RA, SC, VR> { pub(crate) client: Arc>, @@ -388,6 +406,7 @@ pub(crate) struct Environment, RA, SC, V pub(crate) set_id: SetId, pub(crate) voter_set_state: SharedVoterSetState, pub(crate) voting_rule: VR, + pub(crate) metrics: Option } impl, RA, SC, VR> Environment { @@ -400,6 +419,17 @@ impl, RA, SC, VR> Environment { pub telemetry_on_connect: Option>, /// A voting rule used to potentially restrict target votes. pub voting_rule: VR, + /// The prometheus metrics registry. + pub prometheus_registry: Option, } /// Run a GRANDPA voter as a task. Provide configuration and a link to a @@ -557,6 +559,7 @@ pub fn run_grandpa_voter( on_exit, telemetry_on_connect, voting_rule, + prometheus_registry, } = grandpa_params; // NOTE: we have recently removed `run_grandpa_observer` from the public @@ -615,6 +618,7 @@ pub fn run_grandpa_voter( voting_rule, persistent_data, voter_commands_rx, + prometheus_registry, ); let voter_work = voter_work @@ -656,6 +660,7 @@ where voting_rule: VR, persistent_data: PersistentData, voter_commands_rx: mpsc::UnboundedReceiver>>, + prometheus_registry: Option, ) -> Self { let voters = persistent_data.authority_set.current_authorities(); @@ -670,6 +675,7 @@ where authority_set: persistent_data.authority_set.clone(), consensus_changes: persistent_data.consensus_changes.clone(), voter_set_state: persistent_data.set_state.clone(), + metrics: prometheus_registry.map(|registry| Metrics::register(®istry).unwrap()), }); let mut work = VoterWork { @@ -789,6 +795,7 @@ where consensus_changes: self.env.consensus_changes.clone(), network: self.env.network.clone(), voting_rule: self.env.voting_rule.clone(), + metrics: self.env.metrics.clone() }); self.rebuild_voter(); diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index 024f61aba59a1..96a7ec8f84639 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -55,7 +55,7 @@ sc-rpc = { version = "2.0.0-dev", path = "../rpc" } sc-telemetry = { version = "2.0.0-dev", path = "../telemetry" } sc-offchain = { version = "2.0.0-dev", path = "../offchain" } parity-multiaddr = { package = "parity-multiaddr", version = "0.5.0" } -prometheus-exporter = { path = "../../utils/prometheus" , version = "0.8.0-dev"} +prometheus-exporter = { path = "../../utils/prometheus", version = "0.8.0-dev" } sc-tracing = { version = "2.0.0-dev", path = "../tracing" } tracing = "0.1.10" parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 8c5b94a25e3e1..ac57660c1ee1e 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -1031,7 +1031,7 @@ ServiceBuilder< } // Prometheus metrics - let metrics = if let Some((registry, port)) = prometheus_registry_and_port { + let metrics = if let Some((registry, port)) = prometheus_registry_and_port.clone() { let metrics = ServiceMetrics::register(®istry)?; metrics.node_roles.set(u64::from(config.roles.bits())); @@ -1302,6 +1302,7 @@ ServiceBuilder< _telemetry_on_connect_sinks: telemetry_connection_sinks.clone(), keystore, marker: PhantomData::, + prometheus_registry: prometheus_registry_and_port.map(|(r, _)| r) }) } } diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 99b45453411d3..50d8a3472ae77 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -114,6 +114,7 @@ pub struct Service { _offchain_workers: Option>, keystore: sc_keystore::KeyStorePtr, marker: PhantomData, + prometheus_registry: Option, } /// Alias for a an implementation of `futures::future::Executor`. @@ -223,6 +224,9 @@ pub trait AbstractService: 'static + Future> + /// Get a handle to a future that will resolve on exit. fn on_exit(&self) -> ::exit_future::Exit; + + /// Get the prometheus metrics registry, if available. + fn prometheus_registry(&self) -> Option; } impl AbstractService for @@ -326,6 +330,10 @@ where fn on_exit(&self) -> exit_future::Exit { self.exit.clone() } + + fn prometheus_registry(&self) -> Option { + self.prometheus_registry.clone() + } } impl Future for From 2062bb03216406dc6b61a5df797dffaef1d025ef Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Wed, 26 Feb 2020 13:45:44 +0100 Subject: [PATCH 3/6] fix fg tests --- client/finality-grandpa/src/tests.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/client/finality-grandpa/src/tests.rs b/client/finality-grandpa/src/tests.rs index 16b50ccb9f226..e6868db7a855b 100644 --- a/client/finality-grandpa/src/tests.rs +++ b/client/finality-grandpa/src/tests.rs @@ -452,6 +452,7 @@ fn run_to_completion_with( on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + prometheus_registry: None, }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); @@ -583,6 +584,7 @@ fn finalize_3_voters_1_full_observer() { on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + prometheus_registry: None, }; voters.push(run_grandpa_voter(grandpa_params).expect("all in order with client and network")); @@ -746,6 +748,7 @@ fn transition_3_voters_twice_1_full_observer() { on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + prometheus_registry: None, }; let voter = run_grandpa_voter(grandpa_params).expect("all in order with client and network"); @@ -1171,6 +1174,7 @@ fn voter_persists_its_votes() { on_exit: Exit, telemetry_on_connect: None, voting_rule: VotingRulesBuilder::default().build(), + prometheus_registry: None, }; let voter = run_grandpa_voter(grandpa_params) @@ -1520,6 +1524,7 @@ fn voter_catches_up_to_latest_round_when_behind() { on_exit: Exit, telemetry_on_connect: None, voting_rule: (), + prometheus_registry: None, }; Box::pin(run_grandpa_voter(grandpa_params).expect("all in order with client and network")) @@ -1654,6 +1659,7 @@ fn grandpa_environment_respects_voting_rules() { voters: Arc::new(authority_set.current_authorities()), network, voting_rule, + metrics: None, } }; From 3b22f98b6246f5e40521e749c21c08716ccfdf72 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Thu, 27 Feb 2020 16:34:16 +0100 Subject: [PATCH 4/6] Nitpicks --- client/finality-grandpa/src/environment.rs | 7 ++++--- client/finality-grandpa/src/lib.rs | 5 ++++- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index 0437bd73d29c5..c22f4582bdb63 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -382,9 +382,10 @@ pub(crate) struct Metrics { impl Metrics { pub(crate) fn register(registry: &prometheus_exporter::Registry) -> Result { Ok(Self { - finality_grandpa_round: register(Gauge::new( - "finality_grandpa_round", "Highest completed GRANDPA round.", - )?, registry)?, + finality_grandpa_round: register( + Gauge::new("finality_grandpa_round", "Highest completed GRANDPA round.")?, + registry + )?, }) } } diff --git a/client/finality-grandpa/src/lib.rs b/client/finality-grandpa/src/lib.rs index a521823beb0a7..d87e0b1494fca 100644 --- a/client/finality-grandpa/src/lib.rs +++ b/client/finality-grandpa/src/lib.rs @@ -692,7 +692,10 @@ where authority_set: persistent_data.authority_set.clone(), consensus_changes: persistent_data.consensus_changes.clone(), voter_set_state: persistent_data.set_state.clone(), - metrics: prometheus_registry.map(|registry| Metrics::register(®istry).unwrap()), + metrics: prometheus_registry.map(|registry| { + Metrics::register(®istry) + .expect("Other metrics would have failed to register before these; qed") + }), _phantom: PhantomData, }); From fc1ad165b847c2cdc8c457445c388e6b01156932 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Thu, 27 Feb 2020 16:34:16 +0100 Subject: [PATCH 5/6] Nitpicks From 66f245a058db06add9a5b0e95c29d63463959f84 Mon Sep 17 00:00:00 2001 From: Ashley Ruglys Date: Thu, 27 Feb 2020 23:56:59 +0100 Subject: [PATCH 6/6] Fix name of prometheus crate --- client/service/Cargo.toml | 2 +- client/service/src/builder.rs | 4 ++-- client/service/src/error.rs | 4 ++-- client/service/src/lib.rs | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/client/service/Cargo.toml b/client/service/Cargo.toml index d504ab2052541..8443f4e93ae46 100644 --- a/client/service/Cargo.toml +++ b/client/service/Cargo.toml @@ -56,7 +56,7 @@ sc-rpc = { version = "2.0.0-alpha.2", path = "../rpc" } sc-telemetry = { version = "2.0.0-alpha.2", path = "../telemetry" } sc-offchain = { version = "2.0.0-alpha.2", path = "../offchain" } parity-multiaddr = { package = "parity-multiaddr", version = "0.5.0" } -substrate-prometheus-endpoint = { path = "../../utils/prometheus" , version = "0.8.0-alpha.2"} +prometheus-endpoint = { package = "substrate-prometheus-endpoint", path = "../../utils/prometheus" , version = "0.8.0-alpha.2"} sc-tracing = { version = "2.0.0-alpha.2", path = "../tracing" } tracing = "0.1.10" parity-util-mem = { version = "0.5.1", default-features = false, features = ["primitive-types"] } diff --git a/client/service/src/builder.rs b/client/service/src/builder.rs index 934ec51685d84..f4b3201208c78 100644 --- a/client/service/src/builder.rs +++ b/client/service/src/builder.rs @@ -53,7 +53,7 @@ use sysinfo::{get_current_pid, ProcessExt, System, SystemExt}; use sc_telemetry::{telemetry, SUBSTRATE_INFO}; use sp_transaction_pool::{MaintainedTransactionPool, ChainEvent}; use sp_blockchain; -use substrate_prometheus_endpoint::{register, Gauge, U64, F64, Registry, PrometheusError, Opts, GaugeVec}; +use prometheus_endpoint::{register, Gauge, U64, F64, Registry, PrometheusError, Opts, GaugeVec}; struct ServiceMetrics { block_height_number: GaugeVec, @@ -1037,7 +1037,7 @@ ServiceBuilder< metrics.node_roles.set(u64::from(config.roles.bits())); let future = select( - substrate_prometheus_endpoint::init_prometheus(port, registry).boxed(), + prometheus_endpoint::init_prometheus(port, registry).boxed(), exit.clone() ).map(drop); diff --git a/client/service/src/error.rs b/client/service/src/error.rs index adf630e44c02a..5a78a18789230 100644 --- a/client/service/src/error.rs +++ b/client/service/src/error.rs @@ -53,8 +53,8 @@ impl<'a> From<&'a str> for Error { } } -impl From for Error { - fn from(e: substrate_prometheus_endpoint::PrometheusError) -> Self { +impl From for Error { + fn from(e: prometheus_endpoint::PrometheusError) -> Self { Error::Other(format!("Prometheus error: {}", e)) } } diff --git a/client/service/src/lib.rs b/client/service/src/lib.rs index 11f965c961368..c72a966d4b778 100644 --- a/client/service/src/lib.rs +++ b/client/service/src/lib.rs @@ -331,7 +331,7 @@ where self.exit.clone() } - fn prometheus_registry(&self) -> Option { + fn prometheus_registry(&self) -> Option { self.prometheus_registry.clone() } }