From ae7ff5f4b3587182cb1b7c1fc7f93c9f163ae1d6 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Thu, 9 Dec 2021 11:21:27 +0100 Subject: [PATCH] Remove Prometheus metrics prefix (#9543) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Remove Prometheus metrics prefix * Fix line widths * Missed some metrics * Fix CLI * Run rustfmt on modified files * Missing prefixes * Hopefully fix compilation * Rustfmt protocol.rs * Should compile now I guess * Rustfmt Co-authored-by: Bastian Köcher --- client/api/src/notifications.rs | 2 +- client/authority-discovery/src/worker.rs | 14 ++--- client/beefy/src/metrics.rs | 18 ++++-- client/cli/src/commands/run_cmd.rs | 11 ++-- client/consensus/common/src/metrics.rs | 14 +++-- .../src/communication/gossip.rs | 2 +- client/finality-grandpa/src/environment.rs | 6 +- client/finality-grandpa/src/until_imported.rs | 2 +- client/network-gossip/src/state_machine.rs | 4 +- client/network/src/protocol.rs | 9 +-- client/network/src/service/metrics.rs | 63 ++++++++++--------- client/network/src/service/out_events.rs | 6 +- client/network/src/transactions.rs | 2 +- client/proposer-metrics/src/lib.rs | 4 +- client/rpc-servers/src/lib.rs | 4 +- client/rpc-servers/src/middleware.rs | 10 +-- client/service/src/config.rs | 7 ++- client/service/src/metrics.rs | 23 ++++--- client/service/src/task_manager/mod.rs | 8 +-- client/transaction-pool/src/metrics.rs | 12 ++-- client/utils/src/metrics.rs | 6 +- 21 files changed, 125 insertions(+), 102 deletions(-) diff --git a/client/api/src/notifications.rs b/client/api/src/notifications.rs index 1346afd5e54d2..9565fd673acf4 100644 --- a/client/api/src/notifications.rs +++ b/client/api/src/notifications.rs @@ -121,7 +121,7 @@ impl StorageNotifications { let metrics = prometheus_registry.and_then(|r| { CounterVec::new( Opts::new( - "storage_notification_subscribers", + "substrate_storage_notification_subscribers", "Number of subscribers in storage notification sytem", ), &["action"], // added | removed diff --git a/client/authority-discovery/src/worker.rs b/client/authority-discovery/src/worker.rs index ce04e0eb65b15..5ca93b73c8132 100644 --- a/client/authority-discovery/src/worker.rs +++ b/client/authority-discovery/src/worker.rs @@ -733,14 +733,14 @@ impl Metrics { Ok(Self { publish: register( Counter::new( - "authority_discovery_times_published_total", + "substrate_authority_discovery_times_published_total", "Number of times authority discovery has published external addresses.", )?, registry, )?, amount_addresses_last_published: register( Gauge::new( - "authority_discovery_amount_external_addresses_last_published", + "substrate_authority_discovery_amount_external_addresses_last_published", "Number of external addresses published when authority discovery last \ published addresses.", )?, @@ -748,7 +748,7 @@ impl Metrics { )?, requests: register( Counter::new( - "authority_discovery_authority_addresses_requested_total", + "substrate_authority_discovery_authority_addresses_requested_total", "Number of times authority discovery has requested external addresses of a \ single authority.", )?, @@ -756,7 +756,7 @@ impl Metrics { )?, requests_pending: register( Gauge::new( - "authority_discovery_authority_address_requests_pending", + "substrate_authority_discovery_authority_address_requests_pending", "Number of pending authority address requests.", )?, registry, @@ -764,7 +764,7 @@ impl Metrics { dht_event_received: register( CounterVec::new( Opts::new( - "authority_discovery_dht_event_received", + "substrate_authority_discovery_dht_event_received", "Number of dht events received by authority discovery.", ), &["name"], @@ -773,14 +773,14 @@ impl Metrics { )?, handle_value_found_event_failure: register( Counter::new( - "authority_discovery_handle_value_found_event_failure", + "substrate_authority_discovery_handle_value_found_event_failure", "Number of times handling a dht value found event failed.", )?, registry, )?, known_authorities_count: register( Gauge::new( - "authority_discovery_known_authorities_count", + "substrate_authority_discovery_known_authorities_count", "Number of authorities known by authority discovery.", )?, registry, diff --git a/client/beefy/src/metrics.rs b/client/beefy/src/metrics.rs index 0fdc29f97c37a..55edee962a2ee 100644 --- a/client/beefy/src/metrics.rs +++ b/client/beefy/src/metrics.rs @@ -40,28 +40,34 @@ impl Metrics { pub(crate) fn register(registry: &Registry) -> Result { Ok(Self { beefy_validator_set_id: register( - Gauge::new("beefy_validator_set_id", "Current BEEFY active validator set id.")?, + Gauge::new( + "substrate_beefy_validator_set_id", + "Current BEEFY active validator set id.", + )?, registry, )?, beefy_votes_sent: register( - Counter::new("beefy_votes_sent", "Number of votes sent by this node")?, + Counter::new("substrate_beefy_votes_sent", "Number of votes sent by this node")?, registry, )?, beefy_round_concluded: register( - Gauge::new("beefy_round_concluded", "Voting round, that has been concluded")?, + Gauge::new( + "substrate_beefy_round_concluded", + "Voting round, that has been concluded", + )?, registry, )?, beefy_best_block: register( - Gauge::new("beefy_best_block", "Best block finalized by BEEFY")?, + Gauge::new("substrate_beefy_best_block", "Best block finalized by BEEFY")?, registry, )?, beefy_should_vote_on: register( - Gauge::new("beefy_should_vote_on", "Next block, BEEFY should vote on")?, + Gauge::new("substrate_beefy_should_vote_on", "Next block, BEEFY should vote on")?, registry, )?, beefy_skipped_sessions: register( Counter::new( - "beefy_skipped_sessions", + "substrate_beefy_skipped_sessions", "Number of sessions without a signed commitment", )?, registry, diff --git a/client/cli/src/commands/run_cmd.rs b/client/cli/src/commands/run_cmd.rs index ad2f04583c10b..622206fdf2977 100644 --- a/client/cli/src/commands/run_cmd.rs +++ b/client/cli/src/commands/run_cmd.rs @@ -368,10 +368,13 @@ impl CliConfiguration for RunCmd { let interface = if self.prometheus_external { Ipv4Addr::UNSPECIFIED } else { Ipv4Addr::LOCALHOST }; - Some(PrometheusConfig::new_with_default_registry(SocketAddr::new( - interface.into(), - self.prometheus_port.unwrap_or(default_listen_port), - ))) + Some(PrometheusConfig::new_with_default_registry( + SocketAddr::new( + interface.into(), + self.prometheus_port.unwrap_or(default_listen_port), + ), + self.shared_params.chain_id(self.shared_params.dev), + )) }) } diff --git a/client/consensus/common/src/metrics.rs b/client/consensus/common/src/metrics.rs index ade45e3ffb687..ec6ef89f609f4 100644 --- a/client/consensus/common/src/metrics.rs +++ b/client/consensus/common/src/metrics.rs @@ -41,28 +41,34 @@ impl Metrics { Ok(Self { import_queue_processed: register( CounterVec::new( - Opts::new("import_queue_processed_total", "Blocks processed by import queue"), + Opts::new( + "substrate_import_queue_processed_total", + "Blocks processed by import queue", + ), &["result"], // 'success or failure )?, registry, )?, block_verification_time: register( HistogramVec::new( - HistogramOpts::new("block_verification_time", "Time taken to verify blocks"), + HistogramOpts::new( + "substrate_block_verification_time", + "Time taken to verify blocks", + ), &["result"], )?, registry, )?, block_verification_and_import_time: register( Histogram::with_opts(HistogramOpts::new( - "block_verification_and_import_time", + "substrate_block_verification_and_import_time", "Time taken to verify and import blocks", ))?, registry, )?, justification_import_time: register( Histogram::with_opts(HistogramOpts::new( - "justification_import_time", + "substrate_justification_import_time", "Time taken to import justifications", ))?, registry, diff --git a/client/finality-grandpa/src/communication/gossip.rs b/client/finality-grandpa/src/communication/gossip.rs index 2e50a3bac01d9..8a3b6afcad325 100644 --- a/client/finality-grandpa/src/communication/gossip.rs +++ b/client/finality-grandpa/src/communication/gossip.rs @@ -1299,7 +1299,7 @@ impl Metrics { messages_validated: register( CounterVec::new( Opts::new( - "finality_grandpa_communication_gossip_validator_messages", + "substrate_finality_grandpa_communication_gossip_validator_messages", "Number of messages validated by the finality grandpa gossip validator.", ), &["message", "action"], diff --git a/client/finality-grandpa/src/environment.rs b/client/finality-grandpa/src/environment.rs index c79698902e975..1f5b381c1382a 100644 --- a/client/finality-grandpa/src/environment.rs +++ b/client/finality-grandpa/src/environment.rs @@ -404,19 +404,19 @@ impl Metrics { ) -> Result { Ok(Self { finality_grandpa_round: register( - Gauge::new("finality_grandpa_round", "Highest completed GRANDPA round.")?, + Gauge::new("substrate_finality_grandpa_round", "Highest completed GRANDPA round.")?, registry, )?, finality_grandpa_prevotes: register( Counter::new( - "finality_grandpa_prevotes_total", + "substrate_finality_grandpa_prevotes_total", "Total number of GRANDPA prevotes cast locally.", )?, registry, )?, finality_grandpa_precommits: register( Counter::new( - "finality_grandpa_precommits_total", + "substrate_finality_grandpa_precommits_total", "Total number of GRANDPA precommits cast locally.", )?, registry, diff --git a/client/finality-grandpa/src/until_imported.rs b/client/finality-grandpa/src/until_imported.rs index deb6577264347..e2c00b54ea068 100644 --- a/client/finality-grandpa/src/until_imported.rs +++ b/client/finality-grandpa/src/until_imported.rs @@ -100,7 +100,7 @@ impl Metrics { Ok(Self { global_waiting_messages: register( Gauge::new( - "finality_grandpa_until_imported_waiting_messages_number", + "substrate_finality_grandpa_until_imported_waiting_messages_number", "Number of finality grandpa messages waiting within the until imported queue.", )?, registry, diff --git a/client/network-gossip/src/state_machine.rs b/client/network-gossip/src/state_machine.rs index 920b44d8c1e5a..63553f2f16029 100644 --- a/client/network-gossip/src/state_machine.rs +++ b/client/network-gossip/src/state_machine.rs @@ -508,14 +508,14 @@ impl Metrics { Ok(Self { registered_messages: register( Counter::new( - "network_gossip_registered_messages_total", + "substrate_network_gossip_registered_messages_total", "Number of registered messages by the gossip service.", )?, registry, )?, expired_messages: register( Counter::new( - "network_gossip_expired_messages_total", + "substrate_network_gossip_expired_messages_total", "Number of expired messages by the gossip service.", )?, registry, diff --git a/client/network/src/protocol.rs b/client/network/src/protocol.rs index bfaf42d5ff227..abd723f13d206 100644 --- a/client/network/src/protocol.rs +++ b/client/network/src/protocol.rs @@ -132,21 +132,22 @@ impl Metrics { fn register(r: &Registry) -> Result { Ok(Self { peers: { - let g = Gauge::new("sync_peers", "Number of peers we sync with")?; + let g = Gauge::new("substrate_sync_peers", "Number of peers we sync with")?; register(g, r)? }, queued_blocks: { - let g = Gauge::new("sync_queued_blocks", "Number of blocks in import queue")?; + let g = + Gauge::new("substrate_sync_queued_blocks", "Number of blocks in import queue")?; register(g, r)? }, fork_targets: { - let g = Gauge::new("sync_fork_targets", "Number of fork sync targets")?; + let g = Gauge::new("substrate_sync_fork_targets", "Number of fork sync targets")?; register(g, r)? }, justifications: { let g = GaugeVec::new( Opts::new( - "sync_extra_justifications", + "substrate_sync_extra_justifications", "Number of extra justifications requests", ), &["status"], diff --git a/client/network/src/service/metrics.rs b/client/network/src/service/metrics.rs index e33cd4b194d69..2550f255e848c 100644 --- a/client/network/src/service/metrics.rs +++ b/client/network/src/service/metrics.rs @@ -84,54 +84,54 @@ impl Metrics { // This list is ordered alphabetically connections_closed_total: prometheus::register(CounterVec::new( Opts::new( - "sub_libp2p_connections_closed_total", + "substrate_sub_libp2p_connections_closed_total", "Total number of connections closed, by direction and reason" ), &["direction", "reason"] )?, registry)?, connections_opened_total: prometheus::register(CounterVec::new( Opts::new( - "sub_libp2p_connections_opened_total", + "substrate_sub_libp2p_connections_opened_total", "Total number of connections opened by direction" ), &["direction"] )?, registry)?, distinct_peers_connections_closed_total: prometheus::register(Counter::new( - "sub_libp2p_distinct_peers_connections_closed_total", + "substrate_sub_libp2p_distinct_peers_connections_closed_total", "Total number of connections closed with distinct peers" )?, registry)?, distinct_peers_connections_opened_total: prometheus::register(Counter::new( - "sub_libp2p_distinct_peers_connections_opened_total", + "substrate_sub_libp2p_distinct_peers_connections_opened_total", "Total number of connections opened with distinct peers" )?, registry)?, import_queue_blocks_submitted: prometheus::register(Counter::new( - "import_queue_blocks_submitted", + "substrate_import_queue_blocks_submitted", "Number of blocks submitted to the import queue.", )?, registry)?, import_queue_justifications_submitted: prometheus::register(Counter::new( - "import_queue_justifications_submitted", + "substrate_import_queue_justifications_submitted", "Number of justifications submitted to the import queue.", )?, registry)?, incoming_connections_errors_total: prometheus::register(CounterVec::new( Opts::new( - "sub_libp2p_incoming_connections_handshake_errors_total", + "substrate_sub_libp2p_incoming_connections_handshake_errors_total", "Total number of incoming connections that have failed during the \ initial handshake" ), &["reason"] )?, registry)?, incoming_connections_total: prometheus::register(Counter::new( - "sub_libp2p_incoming_connections_total", + "substrate_sub_libp2p_incoming_connections_total", "Total number of incoming connections on the listening sockets" )?, registry)?, issued_light_requests: prometheus::register(Counter::new( - "issued_light_requests", + "substrate_issued_light_requests", "Number of light client requests that our node has issued.", )?, registry)?, kademlia_query_duration: prometheus::register(HistogramVec::new( HistogramOpts { common_opts: Opts::new( - "sub_libp2p_kademlia_query_duration", + "substrate_sub_libp2p_kademlia_query_duration", "Duration of Kademlia queries per query type" ), buckets: prometheus::exponential_buckets(0.5, 2.0, 10) @@ -141,43 +141,44 @@ impl Metrics { )?, registry)?, kademlia_random_queries_total: prometheus::register(CounterVec::new( Opts::new( - "sub_libp2p_kademlia_random_queries_total", + "substrate_sub_libp2p_kademlia_random_queries_total", "Number of random Kademlia queries started" ), &["protocol"] )?, registry)?, kademlia_records_count: prometheus::register(GaugeVec::new( Opts::new( - "sub_libp2p_kademlia_records_count", + "substrate_sub_libp2p_kademlia_records_count", "Number of records in the Kademlia records store" ), &["protocol"] )?, registry)?, kademlia_records_sizes_total: prometheus::register(GaugeVec::new( Opts::new( - "sub_libp2p_kademlia_records_sizes_total", + "substrate_sub_libp2p_kademlia_records_sizes_total", "Total size of all the records in the Kademlia records store" ), &["protocol"] )?, registry)?, kbuckets_num_nodes: prometheus::register(GaugeVec::new( Opts::new( - "sub_libp2p_kbuckets_num_nodes", + "substrate_sub_libp2p_kbuckets_num_nodes", "Number of nodes per kbucket per Kademlia instance" ), &["protocol", "lower_ilog2_bucket_bound"] )?, registry)?, listeners_local_addresses: prometheus::register(Gauge::new( - "sub_libp2p_listeners_local_addresses", "Number of local addresses we're listening on" + "substrate_sub_libp2p_listeners_local_addresses", + "Number of local addresses we're listening on" )?, registry)?, listeners_errors_total: prometheus::register(Counter::new( - "sub_libp2p_listeners_errors_total", + "substrate_sub_libp2p_listeners_errors_total", "Total number of non-fatal errors reported by a listener" )?, registry)?, notifications_sizes: prometheus::register(HistogramVec::new( HistogramOpts { common_opts: Opts::new( - "sub_libp2p_notifications_sizes", + "substrate_sub_libp2p_notifications_sizes", "Sizes of the notifications send to and received from all nodes" ), buckets: prometheus::exponential_buckets(64.0, 4.0, 8) @@ -187,38 +188,40 @@ impl Metrics { )?, registry)?, notifications_streams_closed_total: prometheus::register(CounterVec::new( Opts::new( - "sub_libp2p_notifications_streams_closed_total", + "substrate_sub_libp2p_notifications_streams_closed_total", "Total number of notification substreams that have been closed" ), &["protocol"] )?, registry)?, notifications_streams_opened_total: prometheus::register(CounterVec::new( Opts::new( - "sub_libp2p_notifications_streams_opened_total", + "substrate_sub_libp2p_notifications_streams_opened_total", "Total number of notification substreams that have been opened" ), &["protocol"] )?, registry)?, peerset_num_discovered: prometheus::register(Gauge::new( - "sub_libp2p_peerset_num_discovered", "Number of nodes stored in the peerset manager", + "substrate_sub_libp2p_peerset_num_discovered", + "Number of nodes stored in the peerset manager", )?, registry)?, peerset_num_requested: prometheus::register(Gauge::new( - "sub_libp2p_peerset_num_requested", "Number of nodes that the peerset manager wants us to be connected to", + "substrate_sub_libp2p_peerset_num_requested", + "Number of nodes that the peerset manager wants us to be connected to", )?, registry)?, pending_connections: prometheus::register(Gauge::new( - "sub_libp2p_pending_connections", + "substrate_sub_libp2p_pending_connections", "Number of connections in the process of being established", )?, registry)?, pending_connections_errors_total: prometheus::register(CounterVec::new( Opts::new( - "sub_libp2p_pending_connections_errors_total", + "substrate_sub_libp2p_pending_connections_errors_total", "Total number of pending connection errors" ), &["reason"] )?, registry)?, requests_in_failure_total: prometheus::register(CounterVec::new( Opts::new( - "sub_libp2p_requests_in_failure_total", + "substrate_sub_libp2p_requests_in_failure_total", "Total number of incoming requests that the node has failed to answer" ), &["protocol", "reason"] @@ -226,7 +229,7 @@ impl Metrics { requests_in_success_total: prometheus::register(HistogramVec::new( HistogramOpts { common_opts: Opts::new( - "sub_libp2p_requests_in_success_total", + "substrate_sub_libp2p_requests_in_success_total", "For successful incoming requests, time between receiving the request and \ starting to send the response" ), @@ -237,7 +240,7 @@ impl Metrics { )?, registry)?, requests_out_failure_total: prometheus::register(CounterVec::new( Opts::new( - "sub_libp2p_requests_out_failure_total", + "substrate_sub_libp2p_requests_out_failure_total", "Total number of requests that have failed" ), &["protocol", "reason"] @@ -245,7 +248,7 @@ impl Metrics { requests_out_success_total: prometheus::register(HistogramVec::new( HistogramOpts { common_opts: Opts::new( - "sub_libp2p_requests_out_success_total", + "substrate_sub_libp2p_requests_out_success_total", "For successful outgoing requests, time between a request's start and finish" ), buckets: prometheus::exponential_buckets(0.001, 2.0, 16) @@ -267,7 +270,7 @@ impl BandwidthCounters { fn register(registry: &Registry, sinks: Arc) -> Result<(), PrometheusError> { prometheus::register( SourcedCounter::new( - &Opts::new("sub_libp2p_network_bytes_total", "Total bandwidth usage") + &Opts::new("substrate_sub_libp2p_network_bytes_total", "Total bandwidth usage") .variable_label("direction"), BandwidthCounters(sinks), )?, @@ -298,7 +301,7 @@ impl MajorSyncingGauge { prometheus::register( SourcedGauge::new( &Opts::new( - "sub_libp2p_is_major_syncing", + "substrate_sub_libp2p_is_major_syncing", "Whether the node is performing a major sync or not.", ), MajorSyncingGauge(value), @@ -328,7 +331,7 @@ impl NumConnectedGauge { fn register(registry: &Registry, value: Arc) -> Result<(), PrometheusError> { prometheus::register( SourcedGauge::new( - &Opts::new("sub_libp2p_peers_count", "Number of connected peers"), + &Opts::new("substrate_sub_libp2p_peers_count", "Number of connected peers"), NumConnectedGauge(value), )?, registry, diff --git a/client/network/src/service/out_events.rs b/client/network/src/service/out_events.rs index 2d6241278005b..90888c2371f9f 100644 --- a/client/network/src/service/out_events.rs +++ b/client/network/src/service/out_events.rs @@ -192,7 +192,7 @@ impl Metrics { Ok(Self { events_total: register(CounterVec::new( Opts::new( - "sub_libp2p_out_events_events_total", + "substrate_sub_libp2p_out_events_events_total", "Number of broadcast network events that have been sent or received across all \ channels" ), @@ -200,7 +200,7 @@ impl Metrics { )?, registry)?, notifications_sizes: register(CounterVec::new( Opts::new( - "sub_libp2p_out_events_notifications_sizes", + "substrate_sub_libp2p_out_events_notifications_sizes", "Size of notification events that have been sent or received across all \ channels" ), @@ -208,7 +208,7 @@ impl Metrics { )?, registry)?, num_channels: register(GaugeVec::new( Opts::new( - "sub_libp2p_out_events_num_channels", + "substrate_sub_libp2p_out_events_num_channels", "Number of internal active channels that broadcast network events", ), &["name"] diff --git a/client/network/src/transactions.rs b/client/network/src/transactions.rs index 6d190651160f0..21fc55acd274b 100644 --- a/client/network/src/transactions.rs +++ b/client/network/src/transactions.rs @@ -95,7 +95,7 @@ impl Metrics { Ok(Self { propagated_transactions: register( Counter::new( - "sync_propagated_transactions", + "substrate_sync_propagated_transactions", "Number of transactions propagated to at least one peer", )?, r, diff --git a/client/proposer-metrics/src/lib.rs b/client/proposer-metrics/src/lib.rs index 452a796b73920..8bd626bd07916 100644 --- a/client/proposer-metrics/src/lib.rs +++ b/client/proposer-metrics/src/lib.rs @@ -56,14 +56,14 @@ impl Metrics { Ok(Self { block_constructed: register( Histogram::with_opts(HistogramOpts::new( - "proposer_block_constructed", + "substrate_proposer_block_constructed", "Histogram of time taken to construct new block", ))?, registry, )?, number_of_transactions: register( Gauge::new( - "proposer_number_of_transactions", + "substrate_proposer_number_of_transactions", "Number of transactions included in block", )?, registry, diff --git a/client/rpc-servers/src/lib.rs b/client/rpc-servers/src/lib.rs index 1ac409d6ba89f..82da848343209 100644 --- a/client/rpc-servers/src/lib.rs +++ b/client/rpc-servers/src/lib.rs @@ -90,7 +90,7 @@ impl ServerMetrics { Ok(Self { session_opened: register( Counter::new( - "rpc_sessions_opened", + "substrate_rpc_sessions_opened", "Number of persistent RPC sessions opened", )?, r, @@ -98,7 +98,7 @@ impl ServerMetrics { .into(), session_closed: register( Counter::new( - "rpc_sessions_closed", + "substrate_rpc_sessions_closed", "Number of persistent RPC sessions closed", )?, r, diff --git a/client/rpc-servers/src/middleware.rs b/client/rpc-servers/src/middleware.rs index 00532b0e8d661..a78c0642cb584 100644 --- a/client/rpc-servers/src/middleware.rs +++ b/client/rpc-servers/src/middleware.rs @@ -48,7 +48,7 @@ impl RpcMetrics { requests_started: register( CounterVec::new( Opts::new( - "rpc_requests_started", + "substrate_rpc_requests_started", "Number of RPC requests (not calls) received by the server.", ), &["protocol"], @@ -58,7 +58,7 @@ impl RpcMetrics { requests_finished: register( CounterVec::new( Opts::new( - "rpc_requests_finished", + "substrate_rpc_requests_finished", "Number of RPC requests (not calls) processed by the server.", ), &["protocol"], @@ -68,7 +68,7 @@ impl RpcMetrics { calls_time: register( HistogramVec::new( HistogramOpts::new( - "rpc_calls_time", + "substrate_rpc_calls_time", "Total time [μs] of processed RPC calls", ), &["protocol", "method"], @@ -78,7 +78,7 @@ impl RpcMetrics { calls_started: register( CounterVec::new( Opts::new( - "rpc_calls_started", + "substrate_rpc_calls_started", "Number of received RPC calls (unique un-batched requests)", ), &["protocol", "method"], @@ -88,7 +88,7 @@ impl RpcMetrics { calls_finished: register( CounterVec::new( Opts::new( - "rpc_calls_finished", + "substrate_rpc_calls_finished", "Number of processed RPC calls (unique un-batched requests)", ), &["protocol", "method", "is_error"], diff --git a/client/service/src/config.rs b/client/service/src/config.rs index d3bd4e4e48793..0552baf5c209f 100644 --- a/client/service/src/config.rs +++ b/client/service/src/config.rs @@ -36,7 +36,7 @@ pub use sc_telemetry::TelemetryEndpoints; pub use sc_transaction_pool::Options as TransactionPoolOptions; use sp_core::crypto::SecretString; use std::{ - io, + io, iter, net::SocketAddr, path::{Path, PathBuf}, }; @@ -188,10 +188,11 @@ impl PrometheusConfig { /// Create a new config using the default registry. /// /// The default registry prefixes metrics with `substrate`. - pub fn new_with_default_registry(port: SocketAddr) -> Self { + pub fn new_with_default_registry(port: SocketAddr, chain_id: String) -> Self { + let param = iter::once((String::from("chain"), chain_id)).collect(); Self { port, - registry: Registry::new_custom(Some("substrate".into()), None) + registry: Registry::new_custom(None, Some(param)) .expect("this can only fail if the prefix is empty"), } } diff --git a/client/service/src/metrics.rs b/client/service/src/metrics.rs index 4d3c6df92fee7..54550330d75e5 100644 --- a/client/service/src/metrics.rs +++ b/client/service/src/metrics.rs @@ -55,7 +55,7 @@ impl PrometheusMetrics { register( Gauge::::with_opts( Opts::new( - "build_info", + "substrate_build_info", "A metric with a constant '1' value labeled by name, version", ) .const_label("name", name) @@ -65,8 +65,11 @@ impl PrometheusMetrics { )? .set(1); - register(Gauge::::new("node_roles", "The roles the node is running as")?, ®istry)? - .set(roles); + register( + Gauge::::new("substrate_node_roles", "The roles the node is running as")?, + ®istry, + )? + .set(roles); register_globals(registry)?; @@ -74,7 +77,7 @@ impl PrometheusMetrics { SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap_or_default(); register( Gauge::::new( - "process_start_time_seconds", + "substrate_process_start_time_seconds", "Number of seconds between the UNIX epoch and the moment the process started", )?, registry, @@ -85,20 +88,20 @@ impl PrometheusMetrics { // generic internals block_height: register( GaugeVec::new( - Opts::new("block_height", "Block height info of the chain"), + Opts::new("substrate_block_height", "Block height info of the chain"), &["status"], )?, registry, )?, number_leaves: register( - Gauge::new("number_leaves", "Number of known chain leaves (aka forks)")?, + Gauge::new("substrate_number_leaves", "Number of known chain leaves (aka forks)")?, registry, )?, ready_transactions_number: register( Gauge::new( - "ready_transactions_number", + "substrate_ready_transactions_number", "Number of transactions in the ready queue", )?, registry, @@ -106,16 +109,16 @@ impl PrometheusMetrics { // I/ O database_cache: register( - Gauge::new("database_cache_bytes", "RocksDB cache size in bytes")?, + Gauge::new("substrate_database_cache_bytes", "RocksDB cache size in bytes")?, registry, )?, state_cache: register( - Gauge::new("state_cache_bytes", "State cache size in bytes")?, + Gauge::new("substrate_state_cache_bytes", "State cache size in bytes")?, registry, )?, state_db: register( GaugeVec::new( - Opts::new("state_db_cache_bytes", "State DB cache in bytes"), + Opts::new("substrate_state_db_cache_bytes", "State DB cache in bytes"), &["subtype"], )?, registry, diff --git a/client/service/src/task_manager/mod.rs b/client/service/src/task_manager/mod.rs index 342ea6627be68..e09a351b60927 100644 --- a/client/service/src/task_manager/mod.rs +++ b/client/service/src/task_manager/mod.rs @@ -401,7 +401,7 @@ impl Metrics { poll_duration: register(HistogramVec::new( HistogramOpts { common_opts: Opts::new( - "tasks_polling_duration", + "substrate_tasks_polling_duration", "Duration in seconds of each invocation of Future::poll" ), buckets: exponential_buckets(0.001, 4.0, 9) @@ -411,21 +411,21 @@ impl Metrics { )?, registry)?, poll_start: register(CounterVec::new( Opts::new( - "tasks_polling_started_total", + "substrate_tasks_polling_started_total", "Total number of times we started invoking Future::poll" ), &["task_name", "task_group"] )?, registry)?, tasks_spawned: register(CounterVec::new( Opts::new( - "tasks_spawned_total", + "substrate_tasks_spawned_total", "Total number of tasks that have been spawned on the Service" ), &["task_name", "task_group"] )?, registry)?, tasks_ended: register(CounterVec::new( Opts::new( - "tasks_ended_total", + "substrate_tasks_ended_total", "Total number of tasks for which Future::poll has returned Ready(()) or panicked" ), &["task_name", "reason", "task_group"] diff --git a/client/transaction-pool/src/metrics.rs b/client/transaction-pool/src/metrics.rs index d62d64f13a0a4..7afed21509781 100644 --- a/client/transaction-pool/src/metrics.rs +++ b/client/transaction-pool/src/metrics.rs @@ -56,28 +56,28 @@ impl Metrics { Ok(Self { submitted_transactions: register( Counter::new( - "sub_txpool_submitted_transactions", + "substrate_sub_txpool_submitted_transactions", "Total number of transactions submitted", )?, registry, )?, validations_invalid: register( Counter::new( - "sub_txpool_validations_invalid", + "substrate_sub_txpool_validations_invalid", "Total number of transactions that were removed from the pool as invalid", )?, registry, )?, block_transactions_pruned: register( Counter::new( - "sub_txpool_block_transactions_pruned", + "substrate_sub_txpool_block_transactions_pruned", "Total number of transactions that was requested to be pruned by block events", )?, registry, )?, block_transactions_resubmitted: register( Counter::new( - "sub_txpool_block_transactions_resubmitted", + "substrate_sub_txpool_block_transactions_resubmitted", "Total number of transactions that was requested to be resubmitted by block events", )?, registry, @@ -98,14 +98,14 @@ impl ApiMetrics { Ok(Self { validations_scheduled: register( Counter::new( - "sub_txpool_validations_scheduled", + "substrate_sub_txpool_validations_scheduled", "Total number of transactions scheduled for validation", )?, registry, )?, validations_finished: register( Counter::new( - "sub_txpool_validations_finished", + "substrate_sub_txpool_validations_finished", "Total number of transactions that finished validation", )?, registry, diff --git a/client/utils/src/metrics.rs b/client/utils/src/metrics.rs index 85ccce626bc25..6e85a66e62e5a 100644 --- a/client/utils/src/metrics.rs +++ b/client/utils/src/metrics.rs @@ -29,17 +29,17 @@ use prometheus::{core::GenericCounterVec, Opts}; lazy_static! { pub static ref TOKIO_THREADS_TOTAL: GenericCounter = - GenericCounter::new("tokio_threads_total", "Total number of threads created") + GenericCounter::new("substrate_tokio_threads_total", "Total number of threads created") .expect("Creating of statics doesn't fail. qed"); pub static ref TOKIO_THREADS_ALIVE: GenericGauge = - GenericGauge::new("tokio_threads_alive", "Number of threads alive right now") + GenericGauge::new("substrate_tokio_threads_alive", "Number of threads alive right now") .expect("Creating of statics doesn't fail. qed"); } #[cfg(feature = "metered")] lazy_static! { pub static ref UNBOUNDED_CHANNELS_COUNTER : GenericCounterVec = GenericCounterVec::new( - Opts::new("unbounded_channel_len", "Items in each mpsc::unbounded instance"), + Opts::new("substrate_unbounded_channel_len", "Items in each mpsc::unbounded instance"), &["entity", "action"] // 'name of channel, send|received|dropped ).expect("Creating of statics doesn't fail. qed");