From 10b577096b6e2f0a6413cc8406474630272c6e3f Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Fri, 26 May 2023 15:21:48 +0300 Subject: [PATCH] chore(metrics): restructure crates (#2850) --- Cargo.lock | 33 +++++++------------ Cargo.toml | 2 +- bin/reth/Cargo.toml | 2 +- bin/reth/src/prometheus_exporter.rs | 18 ++++------ crates/consensus/beacon/Cargo.toml | 3 +- crates/consensus/beacon/src/engine/metrics.rs | 6 ++-- crates/metrics/Cargo.toml | 20 +++++++++++ crates/metrics/common/Cargo.toml | 19 ----------- crates/metrics/common/src/lib.rs | 10 ------ .../src => src/common}/metered_sender.rs | 0 crates/metrics/src/common/mod.rs | 1 + crates/metrics/src/lib.rs | 18 ++++++++++ crates/net/downloaders/Cargo.toml | 3 +- crates/net/downloaders/src/metrics.rs | 6 ++-- crates/net/eth-wire/Cargo.toml | 2 +- crates/net/eth-wire/src/p2pstream.rs | 2 +- crates/net/network/Cargo.toml | 6 +--- crates/net/network/src/metrics.rs | 6 ++-- crates/net/network/src/session/active.rs | 2 +- crates/net/network/src/session/mod.rs | 2 +- crates/payload/basic/Cargo.toml | 5 +-- crates/payload/basic/src/metrics.rs | 6 ++-- crates/payload/builder/Cargo.toml | 5 +-- crates/payload/builder/src/metrics.rs | 6 ++-- crates/stages/Cargo.toml | 3 +- crates/stages/src/lib.rs | 4 --- crates/stages/src/pipeline/sync_metrics.rs | 6 ++-- crates/stages/src/stages/execution.rs | 6 ++-- crates/storage/db/Cargo.toml | 4 +-- .../storage/db/src/implementation/mdbx/tx.rs | 2 +- crates/tasks/Cargo.toml | 3 +- crates/tasks/src/metrics.rs | 6 ++-- crates/transaction-pool/Cargo.toml | 6 +--- crates/transaction-pool/src/metrics.rs | 6 ++-- 34 files changed, 110 insertions(+), 119 deletions(-) create mode 100644 crates/metrics/Cargo.toml delete mode 100644 crates/metrics/common/Cargo.toml delete mode 100644 crates/metrics/common/src/lib.rs rename crates/metrics/{common/src => src/common}/metered_sender.rs (100%) create mode 100644 crates/metrics/src/common/mod.rs create mode 100644 crates/metrics/src/lib.rs diff --git a/Cargo.lock b/Cargo.lock index cec94c78e..23060933f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4586,7 +4586,6 @@ dependencies = [ "human_bytes", "hyper", "jemallocator", - "metrics", "metrics-exporter-prometheus", "metrics-util", "pin-project", @@ -4600,6 +4599,7 @@ dependencies = [ "reth-discv4", "reth-downloaders", "reth-interfaces", + "reth-metrics", "reth-net-nat", "reth-network", "reth-network-api", @@ -4653,8 +4653,7 @@ version = "0.1.0" dependencies = [ "futures-core", "futures-util", - "metrics", - "reth-metrics-derive", + "reth-metrics", "reth-payload-builder", "reth-primitives", "reth-provider", @@ -4673,12 +4672,11 @@ version = "0.1.0" dependencies = [ "assert_matches", "futures", - "metrics", "reth-blockchain-tree", "reth-consensus-common", "reth-db", "reth-interfaces", - "reth-metrics-derive", + "reth-metrics", "reth-payload-builder", "reth-primitives", "reth-provider", @@ -4747,7 +4745,6 @@ dependencies = [ "futures", "heapless", "iai", - "metrics", "modular-bitfield", "page_size", "parity-scale-codec", @@ -4762,6 +4759,7 @@ dependencies = [ "reth-db", "reth-interfaces", "reth-libmdbx", + "reth-metrics", "reth-primitives", "secp256k1", "serde", @@ -4828,12 +4826,11 @@ dependencies = [ "futures", "futures-util", "itertools", - "metrics", "pin-project", "rayon", "reth-db", "reth-interfaces", - "reth-metrics-derive", + "reth-metrics", "reth-primitives", "reth-rlp", "reth-tasks", @@ -4888,13 +4885,13 @@ dependencies = [ "futures", "hex", "hex-literal 0.3.4", - "metrics", "pin-project", "proptest", "proptest-derive", "rand 0.8.5", "reth-codecs", "reth-ecies", + "reth-metrics", "reth-primitives", "reth-rlp", "reth-tracing", @@ -4987,7 +4984,7 @@ dependencies = [ ] [[package]] -name = "reth-metrics-common" +name = "reth-metrics" version = "0.1.0" dependencies = [ "metrics", @@ -5050,7 +5047,6 @@ dependencies = [ "humantime-serde", "linked-hash-map", "linked_hash_set", - "metrics", "parking_lot 0.12.1", "pin-project", "rand 0.8.5", @@ -5059,8 +5055,7 @@ dependencies = [ "reth-ecies", "reth-eth-wire", "reth-interfaces", - "reth-metrics-common", - "reth-metrics-derive", + "reth-metrics", "reth-net-common", "reth-network", "reth-network-api", @@ -5103,9 +5098,8 @@ version = "0.1.0" dependencies = [ "futures-util", "hashbrown 0.13.2", - "metrics", "reth-interfaces", - "reth-metrics-derive", + "reth-metrics", "reth-primitives", "reth-revm-primitives", "reth-rlp", @@ -5412,7 +5406,6 @@ dependencies = [ "criterion", "futures-util", "itertools", - "metrics", "num-traits", "paste", "pin-project", @@ -5425,7 +5418,7 @@ dependencies = [ "reth-downloaders", "reth-eth-wire", "reth-interfaces", - "reth-metrics-derive", + "reth-metrics", "reth-primitives", "reth-provider", "reth-revm", @@ -5443,8 +5436,7 @@ version = "0.1.0" dependencies = [ "dyn-clone", "futures-util", - "metrics", - "reth-metrics-derive", + "reth-metrics", "thiserror", "tokio", "tracing", @@ -5471,12 +5463,11 @@ dependencies = [ "bitflags", "fnv", "futures-util", - "metrics", "parking_lot 0.12.1", "paste", "rand 0.8.5", "reth-interfaces", - "reth-metrics-derive", + "reth-metrics", "reth-primitives", "reth-provider", "reth-rlp", diff --git a/Cargo.toml b/Cargo.toml index d240927db..e05b0b95e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,8 +7,8 @@ members = [ "crates/blockchain-tree", "crates/interfaces", "crates/payload/builder", + "crates/metrics", "crates/metrics/metrics-derive", - "crates/metrics/common", "crates/net/common", "crates/net/ecies", "crates/net/eth-wire", diff --git a/bin/reth/Cargo.toml b/bin/reth/Cargo.toml index 55017d416..3783dd3e9 100644 --- a/bin/reth/Cargo.toml +++ b/bin/reth/Cargo.toml @@ -35,6 +35,7 @@ reth-net-nat = { path = "../../crates/net/nat" } reth-payload-builder = { path = "../../crates/payload/builder" } reth-basic-payload-builder = { path = "../../crates/payload/basic" } reth-discv4 = { path = "../../crates/net/discv4" } +reth-metrics = { path = "../../crates/metrics" } jemallocator = { version = "0.5.0", optional = true } # crypto @@ -57,7 +58,6 @@ confy = "0.5" toml = {version = "0.7", features = ["display"]} # metrics -metrics = "0.20.1" metrics-exporter-prometheus = "0.11.0" metrics-util = "0.14.0" diff --git a/bin/reth/src/prometheus_exporter.rs b/bin/reth/src/prometheus_exporter.rs index aa0947ac6..2896f0689 100644 --- a/bin/reth/src/prometheus_exporter.rs +++ b/bin/reth/src/prometheus_exporter.rs @@ -4,7 +4,6 @@ use hyper::{ service::{make_service_fn, service_fn}, Body, Request, Response, Server, }; -use metrics::Unit; use metrics_exporter_prometheus::{PrometheusBuilder, PrometheusHandle}; use metrics_util::layers::{PrefixLayer, Stack}; use reth_db::{ @@ -12,6 +11,7 @@ use reth_db::{ mdbx::{Env, WriteMap}, tables, }; +use reth_metrics::metrics::{self, absolute_counter, describe_counter, Unit}; use std::{convert::Infallible, net::SocketAddr, sync::Arc}; /// Installs Prometheus as the metrics recorder and serves it over HTTP with a hook. @@ -89,10 +89,10 @@ pub(crate) async fn initialize_with_db_metrics( let num_pages = leaf_pages + branch_pages + overflow_pages; let table_size = page_size * num_pages; - metrics::absolute_counter!("db.table_size", table_size as u64, "table" => *table); - metrics::absolute_counter!("db.table_pages", leaf_pages as u64, "table" => *table, "type" => "leaf"); - metrics::absolute_counter!("db.table_pages", branch_pages as u64, "table" => *table, "type" => "branch"); - metrics::absolute_counter!("db.table_pages", overflow_pages as u64, "table" => *table, "type" => "overflow"); + absolute_counter!("db.table_size", table_size as u64, "table" => *table); + absolute_counter!("db.table_pages", leaf_pages as u64, "table" => *table, "type" => "leaf"); + absolute_counter!("db.table_pages", branch_pages as u64, "table" => *table, "type" => "branch"); + absolute_counter!("db.table_pages", overflow_pages as u64, "table" => *table, "type" => "overflow"); } Ok::<(), eyre::Report>(()) @@ -103,12 +103,8 @@ pub(crate) async fn initialize_with_db_metrics( // We describe the metrics after the recorder is installed, otherwise this information is not // registered - metrics::describe_counter!( - "db.table_size", - Unit::Bytes, - "The size of a database table (in bytes)" - ); - metrics::describe_counter!("db.table_pages", "The number of database pages for a table"); + describe_counter!("db.table_size", Unit::Bytes, "The size of a database table (in bytes)"); + describe_counter!("db.table_pages", "The number of database pages for a table"); Ok(()) } diff --git a/crates/consensus/beacon/Cargo.toml b/crates/consensus/beacon/Cargo.toml index 7e8bbed8d..b4ff65601 100644 --- a/crates/consensus/beacon/Cargo.toml +++ b/crates/consensus/beacon/Cargo.toml @@ -17,7 +17,7 @@ reth-provider = { path = "../../storage/provider" } reth-rpc-types = { path = "../../rpc/rpc-types" } reth-tasks = { path = "../../tasks" } reth-payload-builder = { path = "../../payload/builder" } -reth-metrics-derive = { path = "../../metrics/metrics-derive" } +reth-metrics = { path = "../../metrics" } # async tokio = { version = "1.21.2", features = ["sync"] } @@ -27,7 +27,6 @@ futures = "0.3" # misc tracing = { workspace = true } thiserror = "1.0" -metrics = "0.20.1" schnellru = "0.2" [dev-dependencies] diff --git a/crates/consensus/beacon/src/engine/metrics.rs b/crates/consensus/beacon/src/engine/metrics.rs index 8305d422c..c9a62e5ba 100644 --- a/crates/consensus/beacon/src/engine/metrics.rs +++ b/crates/consensus/beacon/src/engine/metrics.rs @@ -1,5 +1,7 @@ -use metrics::Counter; -use reth_metrics_derive::Metrics; +use reth_metrics::{ + metrics::{self, Counter}, + Metrics, +}; /// Beacon consensus engine metrics. #[derive(Metrics)] diff --git a/crates/metrics/Cargo.toml b/crates/metrics/Cargo.toml new file mode 100644 index 000000000..064e9e560 --- /dev/null +++ b/crates/metrics/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "reth-metrics" +version = "0.1.0" +edition = "2021" +license = "MIT OR Apache-2.0" +repository = "https://github.com/paradigmxyz/reth" +description = "reth metrics utilities" + +[dependencies] +# reth +reth-metrics-derive = { path = "./metrics-derive" } + +# metrics +metrics = "0.20.1" + +# async +tokio = { version = "1.21.2", features = ["full"], optional = true } + +[features] +common = ["tokio"] diff --git a/crates/metrics/common/Cargo.toml b/crates/metrics/common/Cargo.toml deleted file mode 100644 index ced323c4f..000000000 --- a/crates/metrics/common/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "reth-metrics-common" -version = "0.1.0" -edition = "2021" -license = "Apache-2.0" -repository = "https://github.com/paradigmxyz/reth" -description = """ -Common metric types across the Reth codebase -""" - -[dependencies] -# reth -reth-metrics-derive = { path = "../../metrics/metrics-derive" } - -# async -tokio = { version = "1.21.2", features = ["full"] } - -# metrics -metrics = "0.20.1" diff --git a/crates/metrics/common/src/lib.rs b/crates/metrics/common/src/lib.rs deleted file mode 100644 index b4cae9b04..000000000 --- a/crates/metrics/common/src/lib.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![warn(missing_docs, unreachable_pub)] -#![deny(unused_must_use, rust_2018_idioms)] -#![doc(test( - no_crate_inject, - attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) -))] - -//! Common metric types that can be used across the Reth codebase - -pub mod metered_sender; diff --git a/crates/metrics/common/src/metered_sender.rs b/crates/metrics/src/common/metered_sender.rs similarity index 100% rename from crates/metrics/common/src/metered_sender.rs rename to crates/metrics/src/common/metered_sender.rs diff --git a/crates/metrics/src/common/mod.rs b/crates/metrics/src/common/mod.rs new file mode 100644 index 000000000..4ab4b4582 --- /dev/null +++ b/crates/metrics/src/common/mod.rs @@ -0,0 +1 @@ +pub mod metered_sender; diff --git a/crates/metrics/src/lib.rs b/crates/metrics/src/lib.rs new file mode 100644 index 000000000..65360ada3 --- /dev/null +++ b/crates/metrics/src/lib.rs @@ -0,0 +1,18 @@ +#![warn(missing_docs, unreachable_pub, unused_crate_dependencies)] +#![deny(unused_must_use, rust_2018_idioms)] +#![doc(test( + no_crate_inject, + attr(deny(warnings, rust_2018_idioms), allow(dead_code, unused_variables)) +))] + +//! Collection of metrics utilities. + +/// Metrics derive macro. +pub use reth_metrics_derive::Metrics; + +/// Implementation of common metric utilities. +#[cfg(feature = "common")] +pub mod common; + +/// Re-export core metrics crate. +pub use metrics; diff --git a/crates/net/downloaders/Cargo.toml b/crates/net/downloaders/Cargo.toml index 4fbecc3c3..9d408df3c 100644 --- a/crates/net/downloaders/Cargo.toml +++ b/crates/net/downloaders/Cargo.toml @@ -13,7 +13,7 @@ reth-interfaces = { path = "../../interfaces" } reth-primitives = { path = "../../primitives" } reth-db = { path = "../../storage/db" } reth-tasks = { path = "../../tasks" } -reth-metrics-derive = { path = "../../metrics/metrics-derive" } +reth-metrics = { path = "../../metrics" } # async futures = "0.3" @@ -25,7 +25,6 @@ tokio-util = { version = "0.7", features = ["codec"] } # misc tracing = { workspace = true } -metrics = "0.20.1" rayon = "1.6.0" # optional deps for the test-utils feature diff --git a/crates/net/downloaders/src/metrics.rs b/crates/net/downloaders/src/metrics.rs index d82561da8..59476ca0c 100644 --- a/crates/net/downloaders/src/metrics.rs +++ b/crates/net/downloaders/src/metrics.rs @@ -1,6 +1,8 @@ -use metrics::{Counter, Gauge}; use reth_interfaces::p2p::error::DownloadError; -use reth_metrics_derive::Metrics; +use reth_metrics::{ + metrics::{self, Counter, Gauge}, + Metrics, +}; /// Common downloader metrics. /// diff --git a/crates/net/eth-wire/Cargo.toml b/crates/net/eth-wire/Cargo.toml index c7c345211..3dfe69427 100644 --- a/crates/net/eth-wire/Cargo.toml +++ b/crates/net/eth-wire/Cargo.toml @@ -17,6 +17,7 @@ reth-codecs = { path = "../../storage/codecs" } reth-primitives = { path = "../../primitives" } reth-ecies = { path = "../ecies" } reth-rlp = { path = "../../rlp", features = ["alloc", "derive", "std", "ethereum-types", "smol_str"] } +reth-metrics = { path = "../../metrics" } # used for Chain and builders ethers-core = { version = "2.0.4", default-features = false} @@ -29,7 +30,6 @@ pin-project = "1.0" tracing = { workspace = true } snap = "1.0.5" smol_str = "0.1" -metrics = "0.20.1" async-trait = "0.1" # arbitrary utils diff --git a/crates/net/eth-wire/src/p2pstream.rs b/crates/net/eth-wire/src/p2pstream.rs index 2026754f8..2faf4c2e8 100644 --- a/crates/net/eth-wire/src/p2pstream.rs +++ b/crates/net/eth-wire/src/p2pstream.rs @@ -7,9 +7,9 @@ use crate::{ DisconnectReason, HelloMessage, }; use futures::{Sink, SinkExt, StreamExt}; -use metrics::counter; use pin_project::pin_project; use reth_codecs::derive_arbitrary; +use reth_metrics::metrics::{self, counter}; use reth_primitives::{ bytes::{Buf, BufMut, Bytes, BytesMut}, hex, diff --git a/crates/net/network/Cargo.toml b/crates/net/network/Cargo.toml index 74767e4e8..f45b49f36 100644 --- a/crates/net/network/Cargo.toml +++ b/crates/net/network/Cargo.toml @@ -30,7 +30,7 @@ reth-rlp-derive = { path = "../../rlp/rlp-derive" } reth-tasks = { path = "../../tasks" } reth-transaction-pool = { path = "../../transaction-pool" } reth-provider = { path = "../../storage/provider"} -reth-metrics-common = { path = "../../metrics/common" } +reth-metrics = { path = "../../metrics", features = ["common"] } reth-rpc-types = { path = "../../rpc/rpc-types" } # async/futures @@ -45,10 +45,6 @@ serde = { version = "1.0", optional = true } humantime-serde = { version = "1.1", optional = true } serde_json = { version = "1.0", optional = true } -# metrics -metrics = "0.20.1" -reth-metrics-derive = { path = "../../metrics/metrics-derive" } - # misc auto_impl = "1" aquamarine = "0.3.0" diff --git a/crates/net/network/src/metrics.rs b/crates/net/network/src/metrics.rs index 2436406f1..273e77e73 100644 --- a/crates/net/network/src/metrics.rs +++ b/crates/net/network/src/metrics.rs @@ -1,6 +1,8 @@ -use metrics::{Counter, Gauge}; use reth_eth_wire::DisconnectReason; -use reth_metrics_derive::Metrics; +use reth_metrics::{ + metrics::{self, Counter, Gauge}, + Metrics, +}; /// Metrics for the entire network, handled by NetworkManager #[derive(Metrics)] diff --git a/crates/net/network/src/session/active.rs b/crates/net/network/src/session/active.rs index c528d496b..3e5943ee6 100644 --- a/crates/net/network/src/session/active.rs +++ b/crates/net/network/src/session/active.rs @@ -19,7 +19,7 @@ use reth_eth_wire::{ DisconnectReason, EthMessage, EthStream, P2PStream, }; use reth_interfaces::p2p::error::RequestError; -use reth_metrics_common::metered_sender::MeteredSender; +use reth_metrics::common::metered_sender::MeteredSender; use reth_net_common::bandwidth_meter::MeteredStream; use reth_primitives::PeerId; use std::{ diff --git a/crates/net/network/src/session/mod.rs b/crates/net/network/src/session/mod.rs index 87a5e26df..b17b5fea2 100644 --- a/crates/net/network/src/session/mod.rs +++ b/crates/net/network/src/session/mod.rs @@ -19,7 +19,7 @@ use reth_eth_wire::{ errors::EthStreamError, DisconnectReason, EthVersion, HelloMessage, Status, UnauthedEthStream, UnauthedP2PStream, }; -use reth_metrics_common::metered_sender::MeteredSender; +use reth_metrics::common::metered_sender::MeteredSender; use reth_net_common::{ bandwidth_meter::{BandwidthMeter, MeteredStream}, stream::HasRemoteAddr, diff --git a/crates/payload/basic/Cargo.toml b/crates/payload/basic/Cargo.toml index 4c2b0e100..0f0bedef4 100644 --- a/crates/payload/basic/Cargo.toml +++ b/crates/payload/basic/Cargo.toml @@ -16,14 +16,11 @@ reth-rlp = { path = "../../rlp" } reth-provider = { path = "../../storage/provider" } reth-payload-builder = { path = "../builder" } reth-tasks = { path = "../../tasks" } +reth-metrics = { path = "../../metrics" } ## ethereum revm = { version = "3" } -# metrics -metrics = "0.20.1" -reth-metrics-derive = { path = "../../metrics/metrics-derive" } - ## async tokio = { version = "1", features = ["sync", "time"] } futures-core = "0.3" diff --git a/crates/payload/basic/src/metrics.rs b/crates/payload/basic/src/metrics.rs index 5425ac24b..560db7b3e 100644 --- a/crates/payload/basic/src/metrics.rs +++ b/crates/payload/basic/src/metrics.rs @@ -1,7 +1,9 @@ //! Metrics for the payload builder impl -use metrics::Counter; -use reth_metrics_derive::Metrics; +use reth_metrics::{ + metrics::{self, Counter}, + Metrics, +}; /// Transaction pool metrics #[derive(Metrics)] diff --git a/crates/payload/builder/Cargo.toml b/crates/payload/builder/Cargo.toml index ed7f526a4..eab97b89a 100644 --- a/crates/payload/builder/Cargo.toml +++ b/crates/payload/builder/Cargo.toml @@ -14,14 +14,11 @@ reth-rpc-types = { path = "../../rpc/rpc-types" } reth-rlp = { path = "../../rlp" } reth-interfaces = { path = "../../interfaces" } reth-revm-primitives = { path = "../../revm/revm-primitives" } +reth-metrics = { path = "../../metrics" } ## ethereum revm-primitives = "1.1" -# metrics -metrics = "0.20.1" -reth-metrics-derive = { path = "../../metrics/metrics-derive" } - ## async tokio = { version = "1", features = ["sync"] } tokio-stream = "0.1" diff --git a/crates/payload/builder/src/metrics.rs b/crates/payload/builder/src/metrics.rs index 0f4113f2a..c2d042d73 100644 --- a/crates/payload/builder/src/metrics.rs +++ b/crates/payload/builder/src/metrics.rs @@ -1,7 +1,9 @@ //! Payload builder service metrics. -use metrics::{Counter, Gauge}; -use reth_metrics_derive::Metrics; +use reth_metrics::{ + metrics::{self, Counter, Gauge}, + Metrics, +}; /// Payload builder service metrics #[derive(Metrics)] diff --git a/crates/stages/Cargo.toml b/crates/stages/Cargo.toml index ef4e361ef..3ccdc78a0 100644 --- a/crates/stages/Cargo.toml +++ b/crates/stages/Cargo.toml @@ -20,7 +20,7 @@ reth-interfaces = { path = "../interfaces" } reth-db = { path = "../storage/db" } reth-codecs = { path = "../storage/codecs" } reth-provider = { path = "../storage/provider" } -reth-metrics-derive = { path = "../metrics/metrics-derive" } +reth-metrics = { path = "../metrics" } reth-trie = { path = "../trie" } # async @@ -32,7 +32,6 @@ pin-project = "1.0.12" # observability tracing = { workspace = true } -metrics = "0.20.1" # misc thiserror = "1.0.37" diff --git a/crates/stages/src/lib.rs b/crates/stages/src/lib.rs index 57008db42..1bdd46e7f 100644 --- a/crates/stages/src/lib.rs +++ b/crates/stages/src/lib.rs @@ -75,7 +75,3 @@ pub use error::*; pub use id::*; pub use pipeline::*; pub use stage::*; - -// NOTE: Needed so the link in the module-level rustdoc works. -#[allow(unused_extern_crates)] -extern crate metrics as metrics_core; diff --git a/crates/stages/src/pipeline/sync_metrics.rs b/crates/stages/src/pipeline/sync_metrics.rs index d1e479422..09f508d26 100644 --- a/crates/stages/src/pipeline/sync_metrics.rs +++ b/crates/stages/src/pipeline/sync_metrics.rs @@ -1,6 +1,8 @@ use crate::StageId; -use metrics::Gauge; -use reth_metrics_derive::Metrics; +use reth_metrics::{ + metrics::{self, Gauge}, + Metrics, +}; use reth_primitives::{BlockNumber, EntitiesCheckpoint, StageCheckpoint, StageUnitCheckpoint}; use std::collections::HashMap; diff --git a/crates/stages/src/stages/execution.rs b/crates/stages/src/stages/execution.rs index 0eb7f7f8e..e91933029 100644 --- a/crates/stages/src/stages/execution.rs +++ b/crates/stages/src/stages/execution.rs @@ -1,5 +1,4 @@ use crate::{ExecInput, ExecOutput, Stage, StageError, StageId, UnwindInput, UnwindOutput}; -use metrics_core::Gauge; use reth_db::{ cursor::{DbCursorRO, DbCursorRW, DbDupCursorRO}, database::Database, @@ -7,7 +6,10 @@ use reth_db::{ tables, transaction::{DbTx, DbTxMut}, }; -use reth_metrics_derive::Metrics; +use reth_metrics::{ + metrics::{self, Gauge}, + Metrics, +}; use reth_primitives::{ constants::MGAS_TO_GAS, Block, BlockNumber, BlockWithSenders, StageCheckpoint, TransactionSigned, U256, diff --git a/crates/storage/db/Cargo.toml b/crates/storage/db/Cargo.toml index a628745ad..b7ea3c2c8 100644 --- a/crates/storage/db/Cargo.toml +++ b/crates/storage/db/Cargo.toml @@ -13,6 +13,7 @@ reth-primitives = { path = "../../primitives" } reth-interfaces = { path = "../../interfaces" } reth-codecs = { path = "../codecs" } reth-libmdbx = { path = "../libmdbx-rs", optional = true , features = ["return-borrowed"] } +reth-metrics = { path = "../../metrics" } # codecs serde = { version = "1.0.*", default-features = false } @@ -29,9 +30,6 @@ secp256k1 = { version = "0.27.0", default-features = false, features = [ ], optional = true } modular-bitfield = "0.11.2" -# metrics -metrics = "0.20.1" - # misc bytes = "1.4" page_size = "0.4.2" diff --git a/crates/storage/db/src/implementation/mdbx/tx.rs b/crates/storage/db/src/implementation/mdbx/tx.rs index aeafd4668..c8a0ddd08 100644 --- a/crates/storage/db/src/implementation/mdbx/tx.rs +++ b/crates/storage/db/src/implementation/mdbx/tx.rs @@ -7,9 +7,9 @@ use crate::{ transaction::{DbTx, DbTxGAT, DbTxMut, DbTxMutGAT}, DatabaseError, }; -use metrics::histogram; use parking_lot::RwLock; use reth_libmdbx::{EnvironmentKind, Transaction, TransactionKind, WriteFlags, DBI, RW}; +use reth_metrics::metrics::{self, histogram}; use std::{marker::PhantomData, sync::Arc, time::Instant}; /// Wrapper for the libmdbx transaction. diff --git a/crates/tasks/Cargo.toml b/crates/tasks/Cargo.toml index ca531a2c9..715e4e81d 100644 --- a/crates/tasks/Cargo.toml +++ b/crates/tasks/Cargo.toml @@ -20,8 +20,7 @@ thiserror = "1.0" dyn-clone = "1.0" ## rpc/metrics -metrics = "0.20.1" -reth-metrics-derive = { path = "../metrics/metrics-derive" } +reth-metrics = { path = "../metrics" } [dev-dependencies] tokio = { version = "1", features = ["sync", "rt", "rt-multi-thread", "time", "macros"] } diff --git a/crates/tasks/src/metrics.rs b/crates/tasks/src/metrics.rs index a56ccfbbe..6d4924045 100644 --- a/crates/tasks/src/metrics.rs +++ b/crates/tasks/src/metrics.rs @@ -1,6 +1,8 @@ //! Task Executor Metrics -use metrics::Counter; -use reth_metrics_derive::Metrics; +use reth_metrics::{ + metrics::{self, Counter}, + Metrics, +}; /// Task Executor Metrics #[derive(Metrics, Clone)] diff --git a/crates/transaction-pool/Cargo.toml b/crates/transaction-pool/Cargo.toml index d5ac34af9..95a8dcda1 100644 --- a/crates/transaction-pool/Cargo.toml +++ b/crates/transaction-pool/Cargo.toml @@ -16,12 +16,12 @@ normal = [ ] [dependencies] - # reth reth-primitives = { path = "../primitives" } reth-provider = { path = "../storage/provider" } reth-interfaces = { path = "../interfaces" } reth-rlp = { path = "../rlp" } +reth-metrics = { path = "../metrics" } # async/futures async-trait = "0.1" @@ -29,10 +29,6 @@ futures-util = "0.3" parking_lot = "0.12" tokio = { version = "1", default-features = false, features = ["sync"] } -# rpc/metrics -metrics = "0.20.1" -reth-metrics-derive = { path = "../metrics/metrics-derive" } - # misc aquamarine = "0.3.0" thiserror = "1.0" diff --git a/crates/transaction-pool/src/metrics.rs b/crates/transaction-pool/src/metrics.rs index f5bc2f04d..cb6ba58fc 100644 --- a/crates/transaction-pool/src/metrics.rs +++ b/crates/transaction-pool/src/metrics.rs @@ -1,7 +1,9 @@ //! Transaction pool metrics. -use metrics::{Counter, Gauge}; -use reth_metrics_derive::Metrics; +use reth_metrics::{ + metrics::{self, Counter, Gauge}, + Metrics, +}; /// Transaction pool metrics #[derive(Metrics)]