Skip to content

Commit

Permalink
Remove Prometheus metrics prefix (paritytech#9543)
Browse files Browse the repository at this point in the history
* 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 <info@kchr.de>
  • Loading branch information
2 people authored and grishasobol committed Mar 28, 2022
1 parent 3455add commit 8cbc62b
Show file tree
Hide file tree
Showing 21 changed files with 125 additions and 102 deletions.
2 changes: 1 addition & 1 deletion client/api/src/notifications.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<Block: BlockT> StorageNotifications<Block> {
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
Expand Down
14 changes: 7 additions & 7 deletions client/authority-discovery/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -733,38 +733,38 @@ 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.",
)?,
registry,
)?,
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.",
)?,
registry,
)?,
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,
)?,
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"],
Expand All @@ -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,
Expand Down
18 changes: 12 additions & 6 deletions client/beefy/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,28 +40,34 @@ impl Metrics {
pub(crate) fn register(registry: &Registry) -> Result<Self, PrometheusError> {
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,
Expand Down
11 changes: 7 additions & 4 deletions client/cli/src/commands/run_cmd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
))
})
}

Expand Down
14 changes: 10 additions & 4 deletions client/consensus/common/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion client/finality-grandpa/src/communication/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
Expand Down
6 changes: 3 additions & 3 deletions client/finality-grandpa/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,19 +404,19 @@ impl Metrics {
) -> Result<Self, PrometheusError> {
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,
Expand Down
2 changes: 1 addition & 1 deletion client/finality-grandpa/src/until_imported.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions client/network-gossip/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
9 changes: 5 additions & 4 deletions client/network/src/protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,21 +132,22 @@ impl Metrics {
fn register(r: &Registry) -> Result<Self, PrometheusError> {
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"],
Expand Down
Loading

0 comments on commit 8cbc62b

Please sign in to comment.