From 715e98268a23d4237bc575ba6eb5a5f824c01f33 Mon Sep 17 00:00:00 2001
From: Marcin S <marcin@bytedude.com>
Date: Fri, 6 Jan 2023 10:01:23 -0500
Subject: [PATCH] Use `polkadot-node-metrics` where possible (#6484)

See https://github.com/paritytech/polkadot/issues/6015. (Doesn't close yet,
there might be more we can do.)
---
 polkadot/Cargo.lock                                        | 7 +++++--
 polkadot/node/core/candidate-validation/Cargo.toml         | 5 +++--
 polkadot/node/core/candidate-validation/src/metrics.rs     | 2 +-
 polkadot/node/core/chain-api/Cargo.toml                    | 2 +-
 polkadot/node/core/chain-api/src/metrics.rs                | 2 +-
 polkadot/node/core/runtime-api/Cargo.toml                  | 2 +-
 polkadot/node/core/runtime-api/src/metrics.rs              | 2 +-
 polkadot/node/network/approval-distribution/Cargo.toml     | 4 ++--
 polkadot/node/network/approval-distribution/src/metrics.rs | 2 +-
 polkadot/node/network/bridge/Cargo.toml                    | 5 +++--
 polkadot/node/network/bridge/src/metrics.rs                | 2 +-
 11 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/polkadot/Cargo.lock b/polkadot/Cargo.lock
index 2a4954d791d..6a9f908457a 100644
--- a/polkadot/Cargo.lock
+++ b/polkadot/Cargo.lock
@@ -6355,6 +6355,7 @@ dependencies = [
  "env_logger 0.9.0",
  "futures",
  "log",
+ "polkadot-node-metrics",
  "polkadot-node-network-protocol",
  "polkadot-node-primitives",
  "polkadot-node-subsystem",
@@ -6650,6 +6651,7 @@ dependencies = [
  "futures-timer",
  "parity-scale-codec",
  "parking_lot 0.12.1",
+ "polkadot-node-metrics",
  "polkadot-node-network-protocol",
  "polkadot-node-subsystem",
  "polkadot-node-subsystem-test-helpers",
@@ -6804,6 +6806,7 @@ dependencies = [
  "futures-timer",
  "parity-scale-codec",
  "polkadot-node-core-pvf",
+ "polkadot-node-metrics",
  "polkadot-node-primitives",
  "polkadot-node-subsystem",
  "polkadot-node-subsystem-test-helpers",
@@ -6824,10 +6827,10 @@ dependencies = [
  "futures",
  "maplit",
  "parity-scale-codec",
+ "polkadot-node-metrics",
  "polkadot-node-primitives",
  "polkadot-node-subsystem",
  "polkadot-node-subsystem-test-helpers",
- "polkadot-node-subsystem-util",
  "polkadot-primitives",
  "sc-client-api",
  "sc-consensus-babe",
@@ -6985,11 +6988,11 @@ version = "0.9.33"
 dependencies = [
  "futures",
  "lru",
+ "polkadot-node-metrics",
  "polkadot-node-primitives",
  "polkadot-node-subsystem",
  "polkadot-node-subsystem-test-helpers",
  "polkadot-node-subsystem-types",
- "polkadot-node-subsystem-util",
  "polkadot-primitives",
  "polkadot-primitives-test-helpers",
  "sp-api",
diff --git a/polkadot/node/core/candidate-validation/Cargo.toml b/polkadot/node/core/candidate-validation/Cargo.toml
index 56fa0e08115..28731e1f25b 100644
--- a/polkadot/node/core/candidate-validation/Cargo.toml
+++ b/polkadot/node/core/candidate-validation/Cargo.toml
@@ -16,8 +16,8 @@ parity-scale-codec = { version = "3.1.5", default-features = false, features = [
 polkadot-primitives = { path = "../../../primitives" }
 polkadot-parachain = { path = "../../../parachain" }
 polkadot-node-primitives = { path = "../../primitives" }
-polkadot-node-subsystem = {path = "../../subsystem" }
-polkadot-node-subsystem-util = { path = "../../subsystem-util" }
+polkadot-node-subsystem = { path = "../../subsystem" }
+polkadot-node-metrics = { path = "../../metrics" }
 
 [target.'cfg(not(any(target_os = "android", target_os = "unknown")))'.dependencies]
 polkadot-node-core-pvf = { path = "../pvf" }
@@ -27,5 +27,6 @@ sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master
 futures = { version = "0.3.21", features = ["thread-pool"] }
 assert_matches = "1.4.0"
 polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
+polkadot-node-subsystem-util = { path = "../../subsystem-util" }
 sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
 test-helpers = { package = "polkadot-primitives-test-helpers", path = "../../../primitives/test-helpers" }
diff --git a/polkadot/node/core/candidate-validation/src/metrics.rs b/polkadot/node/core/candidate-validation/src/metrics.rs
index 64112c6a387..344d9502925 100644
--- a/polkadot/node/core/candidate-validation/src/metrics.rs
+++ b/polkadot/node/core/candidate-validation/src/metrics.rs
@@ -15,7 +15,7 @@
 // along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
 
 use super::{ValidationFailed, ValidationResult};
-use polkadot_node_subsystem_util::metrics::{self, prometheus};
+use polkadot_node_metrics::metrics::{self, prometheus};
 
 #[derive(Clone)]
 pub(crate) struct MetricsInner {
diff --git a/polkadot/node/core/chain-api/Cargo.toml b/polkadot/node/core/chain-api/Cargo.toml
index 571b840120f..ec4d0bc9a3d 100644
--- a/polkadot/node/core/chain-api/Cargo.toml
+++ b/polkadot/node/core/chain-api/Cargo.toml
@@ -9,8 +9,8 @@ futures = "0.3.21"
 gum = { package = "tracing-gum", path = "../../gum" }
 sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
 polkadot-primitives = { path = "../../../primitives" }
+polkadot-node-metrics = { path = "../../metrics" }
 polkadot-node-subsystem = {path = "../../subsystem" }
-polkadot-node-subsystem-util = { path = "../../subsystem-util" }
 sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
 sc-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
 
diff --git a/polkadot/node/core/chain-api/src/metrics.rs b/polkadot/node/core/chain-api/src/metrics.rs
index 23f455729e1..34c258b8456 100644
--- a/polkadot/node/core/chain-api/src/metrics.rs
+++ b/polkadot/node/core/chain-api/src/metrics.rs
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
 
-use polkadot_node_subsystem_util::metrics::{self, prometheus};
+use polkadot_node_metrics::metrics::{self, prometheus};
 
 #[derive(Clone)]
 pub(crate) struct MetricsInner {
diff --git a/polkadot/node/core/runtime-api/Cargo.toml b/polkadot/node/core/runtime-api/Cargo.toml
index b342e8aad98..7d8ed54e812 100644
--- a/polkadot/node/core/runtime-api/Cargo.toml
+++ b/polkadot/node/core/runtime-api/Cargo.toml
@@ -12,9 +12,9 @@ lru = "0.8"
 sp-consensus-babe = { git = "https://github.com/paritytech/substrate", branch = "master" }
 
 polkadot-primitives = { path = "../../../primitives" }
+polkadot-node-metrics = { path = "../../metrics" }
 polkadot-node-subsystem = { path = "../../subsystem" }
 polkadot-node-subsystem-types = { path = "../../subsystem-types" }
-polkadot-node-subsystem-util = { path = "../../subsystem-util" }
 
 [dev-dependencies]
 sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
diff --git a/polkadot/node/core/runtime-api/src/metrics.rs b/polkadot/node/core/runtime-api/src/metrics.rs
index c6affaf3891..d9459d1ad57 100644
--- a/polkadot/node/core/runtime-api/src/metrics.rs
+++ b/polkadot/node/core/runtime-api/src/metrics.rs
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
 
-use polkadot_node_subsystem_util::metrics::{self, prometheus};
+use polkadot_node_metrics::metrics::{self, prometheus};
 
 #[derive(Clone)]
 pub(crate) struct MetricsInner {
diff --git a/polkadot/node/network/approval-distribution/Cargo.toml b/polkadot/node/network/approval-distribution/Cargo.toml
index 4138446b185..6df854072aa 100644
--- a/polkadot/node/network/approval-distribution/Cargo.toml
+++ b/polkadot/node/network/approval-distribution/Cargo.toml
@@ -5,10 +5,10 @@ authors.workspace = true
 edition.workspace = true
 
 [dependencies]
-polkadot-node-primitives = { path = "../../primitives" }
+polkadot-node-metrics = { path = "../../metrics" }
 polkadot-node-network-protocol = { path = "../protocol" }
+polkadot-node-primitives = { path = "../../primitives" }
 polkadot-node-subsystem = { path = "../../subsystem" }
-polkadot-node-subsystem-util = { path = "../../subsystem-util" }
 polkadot-primitives = { path = "../../../primitives" }
 rand = "0.8"
 
diff --git a/polkadot/node/network/approval-distribution/src/metrics.rs b/polkadot/node/network/approval-distribution/src/metrics.rs
index b14e54c5740..47bae7065a0 100644
--- a/polkadot/node/network/approval-distribution/src/metrics.rs
+++ b/polkadot/node/network/approval-distribution/src/metrics.rs
@@ -14,7 +14,7 @@
 // You should have received a copy of the GNU General Public License
 // along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
 
-use polkadot_node_subsystem_util::metrics::{prometheus, Metrics as MetricsTrait};
+use polkadot_node_metrics::metrics::{prometheus, Metrics as MetricsTrait};
 
 /// Approval Distribution metrics.
 #[derive(Default, Clone)]
diff --git a/polkadot/node/network/bridge/Cargo.toml b/polkadot/node/network/bridge/Cargo.toml
index 56208ba6a3a..2d68cdb4d80 100644
--- a/polkadot/node/network/bridge/Cargo.toml
+++ b/polkadot/node/network/bridge/Cargo.toml
@@ -14,10 +14,10 @@ parity-scale-codec = { version = "3.1.5", default-features = false, features = [
 sc-network = { git = "https://github.com/paritytech/substrate", branch = "master" }
 sc-network-common = { git = "https://github.com/paritytech/substrate", branch = "master" }
 sp-consensus = { git = "https://github.com/paritytech/substrate", branch = "master" }
+polkadot-node-metrics = { path = "../../metrics"}
+polkadot-node-network-protocol = { path = "../protocol" }
 polkadot-node-subsystem = {path = "../../subsystem" }
 polkadot-overseer = { path = "../../overseer" }
-polkadot-node-network-protocol = { path = "../protocol" }
-polkadot-node-subsystem-util = { path = "../../subsystem-util"}
 parking_lot = "0.12.0"
 bytes = "1"
 fatality = "0.0.6"
@@ -26,6 +26,7 @@ thiserror = "1"
 [dev-dependencies]
 assert_matches = "1.4.0"
 polkadot-node-subsystem-test-helpers = { path = "../../subsystem-test-helpers" }
+polkadot-node-subsystem-util = { path = "../../subsystem-util"}
 sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
 sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "master" }
 futures-timer = "3"
diff --git a/polkadot/node/network/bridge/src/metrics.rs b/polkadot/node/network/bridge/src/metrics.rs
index 52b3629a66a..5ca392ee33f 100644
--- a/polkadot/node/network/bridge/src/metrics.rs
+++ b/polkadot/node/network/bridge/src/metrics.rs
@@ -15,7 +15,7 @@
 // along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
 
 use super::{PeerSet, ProtocolVersion};
-use polkadot_node_subsystem_util::metrics::{self, prometheus};
+use polkadot_node_metrics::metrics::{self, prometheus};
 
 /// Metrics for the network bridge.
 #[derive(Clone, Default)]
-- 
GitLab