diff --git a/.gitignore b/.gitignore index 375738f67093e..b74124ca9c157 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ go/bin/ src/**/target src/**/target_tarpaulin target/ +target-bisector-*/ src/proto/ src/prost/src/*.rs src/prost/src/sim/*.rs diff --git a/Cargo.lock b/Cargo.lock index 9a83f31ffbd98..b8d705132c8f0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -8917,14 +8917,12 @@ dependencies = [ "ethnum", "expect-test", "fixedbitset 0.5.0", - "fs-err", "futures", "governor", "hex", "http 0.2.9", "http-body", "humantime", - "hyper", "hytra", "itertools 0.12.0", "itoa", @@ -8933,7 +8931,6 @@ dependencies = [ "lru 0.7.6", "mach2", "madsim-tokio", - "madsim-tonic", "memcomparable", "more-asserts", "num-integer", @@ -8955,12 +8952,14 @@ dependencies = [ "regex", "reqwest", "risingwave-fields-derive", + "risingwave_common_metrics", "risingwave_common_proc_macro", "risingwave_error", "risingwave_pb", "rust_decimal", "rusty-fork", - "rw_futures_util", + "rw_iter_util", + "rw_resource_util", "ryu", "serde", "serde_bytes", @@ -9005,6 +9004,38 @@ dependencies = [ "tracing", ] +[[package]] +name = "risingwave_common_metrics" +version = "1.7.0-alpha" +dependencies = [ + "bytes", + "clap", + "darwin-libproc", + "easy-ext", + "futures", + "http 0.2.9", + "http-body", + "hyper", + "hytra", + "itertools 0.12.0", + "libc", + "mach2", + "madsim-tokio", + "madsim-tonic", + "parking_lot 0.12.1", + "pin-project-lite", + "procfs 0.16.0", + "prometheus", + "rw_iter_util", + "rw_resource_util", + "serde", + "thiserror-ext", + "tower-layer", + "tower-service", + "tracing", + "tracing-subscriber", +] + [[package]] name = "risingwave_common_proc_macro" version = "1.7.0-alpha" @@ -10639,6 +10670,24 @@ dependencies = [ "tokio", ] +[[package]] +name = "rw_iter_util" +version = "0.0.0" +dependencies = [ + "itertools 0.12.0", +] + +[[package]] +name = "rw_resource_util" +version = "0.0.0" +dependencies = [ + "fs-err", + "sysinfo", + "tempfile", + "thiserror-ext", + "tracing", +] + [[package]] name = "ryu" version = "1.0.15" diff --git a/Cargo.toml b/Cargo.toml index 8d4282e4e58eb..ae63068391aa6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ members = [ "src/common/common_service", "src/common/fields-derive", "src/common/heap_profiling", + "src/common/metrics", "src/compute", "src/connector", "src/connector/with_options", @@ -54,8 +55,10 @@ members = [ "src/tests/state_cleaning_test", "src/utils/delta_btree_map", "src/utils/futures_util", + "src/utils/iter_util", "src/utils/local_stats_alloc", "src/utils/pgwire", + "src/utils/resource_util", "src/utils/runtime", "src/utils/sync-point", "src/utils/variables", @@ -166,6 +169,7 @@ risingwave_cmd = { path = "./src/cmd" } risingwave_common = { path = "./src/common" } risingwave_common_service = { path = "./src/common/common_service" } risingwave_common_heap_profiling = { path = "./src/common/heap_profiling" } +risingwave_common_metrics = { path = "./src/common/metrics" } risingwave_compactor = { path = "./src/storage/compactor" } risingwave_compute = { path = "./src/compute" } risingwave_ctl = { path = "./src/ctl" } @@ -199,6 +203,8 @@ risingwave_variables = { path = "./src/utils/variables" } risingwave_java_binding = { path = "./src/java_binding" } risingwave_jni_core = { path = "src/jni_core" } rw_futures_util = { path = "src/utils/futures_util" } +rw_resource_util = { path = "src/utils/resource_util" } +rw_iter_util = { path = "src/utils/iter_util" } [workspace.lints.rust] # `forbid` will also prevent the misuse of `#[allow(unused)]` diff --git a/src/common/Cargo.toml b/src/common/Cargo.toml index 5fd7a74753030..03561ca289237 100644 --- a/src/common/Cargo.toml +++ b/src/common/Cargo.toml @@ -45,13 +45,11 @@ enum-as-inner = "0.6" enumflags2 = { version = "0.7.8" } ethnum = { version = "1", features = ["serde"] } fixedbitset = { version = "0.5", features = ["std"] } -fs-err = "2" futures = { version = "0.3", default-features = false, features = ["alloc"] } governor = { version = "0.6", default-features = false, features = ["std"] } hex = "0.4.3" http = "0.2" humantime = "2.1" -hyper = "0.14" hytra = { workspace = true } itertools = "0.12" itoa = "1.0" @@ -79,11 +77,13 @@ rand = "0.8" regex = "1" reqwest = { version = "0.11", features = ["json"] } risingwave-fields-derive = { path = "./fields-derive" } +risingwave_common_metrics = { path = "./metrics" } risingwave_common_proc_macro = { path = "./proc_macro" } risingwave_error = { workspace = true } risingwave_pb = { workspace = true } rust_decimal = { version = "1", features = ["db-postgres", "maths"] } -rw_futures_util = { workspace = true } +rw_iter_util = { workspace = true } +rw_resource_util = { workspace = true } ryu = "1.0" serde = { version = "1", features = ["derive"] } serde_bytes = "0.11" @@ -108,7 +108,6 @@ tokio = { version = "0.2", package = "madsim-tokio", features = [ "signal", ] } toml = "0.8" -tonic = { workspace = true } tracing = "0.1" tracing-futures = { version = "0.2", features = ["futures-03"] } tracing-opentelemetry = { workspace = true } @@ -129,7 +128,7 @@ libc = "0.2" [target.'cfg(target_os = "macos")'.dependencies] darwin-libproc = { git = "https://github.com/risingwavelabs/darwin-libproc.git", rev = "a502be24bd0971463f5bcbfe035a248d8ba503b7" } -libc = "0.2.148" +libc = "0.2" mach2 = "0.4" [dev-dependencies] diff --git a/src/common/metrics/Cargo.toml b/src/common/metrics/Cargo.toml new file mode 100644 index 0000000000000..46d497b8768c9 --- /dev/null +++ b/src/common/metrics/Cargo.toml @@ -0,0 +1,52 @@ +[package] +name = "risingwave_common_metrics" +version = { workspace = true } +edition = { workspace = true } +homepage = { workspace = true } +keywords = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[package.metadata.cargo-machete] +ignored = ["workspace-hack"] + +[package.metadata.cargo-udeps.ignore] +normal = ["workspace-hack"] + +[dependencies] +bytes = "1" +clap = { version = "4", features = ["derive"] } +easy-ext = "1" +futures = { version = "0.3", default-features = false, features = ["alloc"] } +http = "0.2" +hyper = { version = "0.14", features = ["client"] } +hytra = { workspace = true } +itertools = "0.12" +parking_lot = "0.12" +pin-project-lite = "0.2" +prometheus = { version = "0.13" } +rw_iter_util = { workspace = true } +rw_resource_util = { workspace = true } +serde = { version = "1", features = ["derive"] } +thiserror-ext = { workspace = true } +tokio = { version = "0.2", package = "madsim-tokio" } +tonic = { workspace = true } +tracing = "0.1" +tracing-subscriber = "0.3.17" + +[target.'cfg(not(madsim))'.dependencies] +http-body = "0.4.5" +tower-layer = "0.3.2" +tower-service = "0.3.2" +[target.'cfg(target_os = "linux")'.dependencies] +procfs = { version = "0.16", default-features = false } +libc = "0.2" + +[target.'cfg(target_os = "macos")'.dependencies] +darwin-libproc = { git = "https://github.com/risingwavelabs/darwin-libproc.git", rev = "a502be24bd0971463f5bcbfe035a248d8ba503b7" } +libc = "0.2" +mach2 = "0.4" + +[lints] +workspace = true diff --git a/src/common/src/metrics/error_metrics.rs b/src/common/metrics/src/error_metrics.rs similarity index 99% rename from src/common/src/metrics/error_metrics.rs rename to src/common/metrics/src/error_metrics.rs index 0a45109a0812d..934920b6c4986 100644 --- a/src/common/src/metrics/error_metrics.rs +++ b/src/common/metrics/src/error_metrics.rs @@ -20,9 +20,9 @@ use parking_lot::Mutex; use prometheus::core::{Collector, Desc}; use prometheus::proto::{Gauge, LabelPair, Metric, MetricFamily}; use prometheus::Registry; +use rw_iter_util::ZipEqFast; use crate::monitor::GLOBAL_METRICS_REGISTRY; -use crate::util::iter_util::ZipEqFast; pub struct ErrorMetric { payload: Arc>>, diff --git a/src/common/src/metrics/guarded_metrics.rs b/src/common/metrics/src/guarded_metrics.rs similarity index 94% rename from src/common/src/metrics/guarded_metrics.rs rename to src/common/metrics/src/guarded_metrics.rs index f1f8bdc9c8765..9c0919d7a420b 100644 --- a/src/common/src/metrics/guarded_metrics.rs +++ b/src/common/metrics/src/guarded_metrics.rs @@ -58,9 +58,8 @@ macro_rules! register_guarded_histogram_vec_with_registry { ($HOPTS:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{ let inner = prometheus::HistogramVec::new($HOPTS, $LABELS_NAMES); inner.and_then(|inner| { - let inner = $crate::metrics::__extract_histogram_builder(inner); - let label_guarded = - $crate::metrics::LabelGuardedHistogramVec::new(inner, { $LABELS_NAMES }); + let inner = $crate::__extract_histogram_builder(inner); + let label_guarded = $crate::LabelGuardedHistogramVec::new(inner, { $LABELS_NAMES }); let result = ($REGISTRY).register(Box::new(label_guarded.clone())); result.map(move |()| label_guarded) }) @@ -72,9 +71,8 @@ macro_rules! register_guarded_gauge_vec_with_registry { ($NAME:expr, $HELP:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{ let inner = prometheus::GaugeVec::new(prometheus::opts!($NAME, $HELP), $LABELS_NAMES); inner.and_then(|inner| { - let inner = $crate::metrics::__extract_gauge_builder(inner); - let label_guarded = - $crate::metrics::LabelGuardedGaugeVec::new(inner, { $LABELS_NAMES }); + let inner = $crate::__extract_gauge_builder(inner); + let label_guarded = $crate::LabelGuardedGaugeVec::new(inner, { $LABELS_NAMES }); let result = ($REGISTRY).register(Box::new(label_guarded.clone())); result.map(move |()| label_guarded) }) @@ -86,9 +84,8 @@ macro_rules! register_guarded_int_gauge_vec_with_registry { ($NAME:expr, $HELP:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{ let inner = prometheus::IntGaugeVec::new(prometheus::opts!($NAME, $HELP), $LABELS_NAMES); inner.and_then(|inner| { - let inner = $crate::metrics::__extract_gauge_builder(inner); - let label_guarded = - $crate::metrics::LabelGuardedIntGaugeVec::new(inner, { $LABELS_NAMES }); + let inner = $crate::__extract_gauge_builder(inner); + let label_guarded = $crate::LabelGuardedIntGaugeVec::new(inner, { $LABELS_NAMES }); let result = ($REGISTRY).register(Box::new(label_guarded.clone())); result.map(move |()| label_guarded) }) @@ -100,9 +97,8 @@ macro_rules! register_guarded_int_counter_vec_with_registry { ($NAME:expr, $HELP:expr, $LABELS_NAMES:expr, $REGISTRY:expr $(,)?) => {{ let inner = prometheus::IntCounterVec::new(prometheus::opts!($NAME, $HELP), $LABELS_NAMES); inner.and_then(|inner| { - let inner = $crate::metrics::__extract_counter_builder(inner); - let label_guarded = - $crate::metrics::LabelGuardedIntCounterVec::new(inner, { $LABELS_NAMES }); + let inner = $crate::__extract_counter_builder(inner); + let label_guarded = $crate::LabelGuardedIntCounterVec::new(inner, { $LABELS_NAMES }); let result = ($REGISTRY).register(Box::new(label_guarded.clone())); result.map(move |()| label_guarded) }) @@ -396,7 +392,7 @@ impl LabelGuardedMetric { mod tests { use prometheus::core::Collector; - use crate::metrics::LabelGuardedIntCounterVec; + use crate::LabelGuardedIntCounterVec; #[test] fn test_label_guarded_metrics_drop() { diff --git a/src/common/src/metrics.rs b/src/common/metrics/src/lib.rs similarity index 68% rename from src/common/src/metrics.rs rename to src/common/metrics/src/lib.rs index 32129732159ef..a2e4156b525d1 100644 --- a/src/common/src/metrics.rs +++ b/src/common/metrics/src/lib.rs @@ -12,6 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(lazy_cell)] +#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] +#![feature(array_methods)] use std::ops::Deref; use std::sync::LazyLock; @@ -23,10 +27,9 @@ use tracing_subscriber::layer::Context; use tracing_subscriber::registry::LookupSpan; use tracing_subscriber::Layer; -use crate::monitor::GLOBAL_METRICS_REGISTRY; - mod error_metrics; mod guarded_metrics; +pub mod monitor; mod relabeled_metric; pub use error_metrics::*; @@ -87,7 +90,7 @@ impl MetricsLayer { #[allow(clippy::new_without_default)] pub fn new() -> Self { static AWS_SDK_RETRY_COUNTS: LazyLock> = LazyLock::new(|| { - let registry = GLOBAL_METRICS_REGISTRY.deref(); + let registry = crate::monitor::GLOBAL_METRICS_REGISTRY.deref(); register_int_counter_with_registry!( "aws_sdk_retry_counts", "Total number of aws sdk retry happens", @@ -101,3 +104,39 @@ impl MetricsLayer { } } } + +#[derive(Debug, Default, Clone, Copy, serde::Serialize, serde::Deserialize)] +pub enum MetricLevel { + #[default] + Disabled = 0, + Critical = 1, + Info = 2, + Debug = 3, +} + +impl clap::ValueEnum for MetricLevel { + fn value_variants<'a>() -> &'a [Self] { + &[Self::Disabled, Self::Critical, Self::Info, Self::Debug] + } + + fn to_possible_value<'a>(&self) -> ::std::option::Option { + match self { + Self::Disabled => Some(clap::builder::PossibleValue::new("disabled").alias("0")), + Self::Critical => Some(clap::builder::PossibleValue::new("critical")), + Self::Info => Some(clap::builder::PossibleValue::new("info").alias("1")), + Self::Debug => Some(clap::builder::PossibleValue::new("debug")), + } + } +} + +impl PartialEq for MetricLevel { + fn eq(&self, other: &Self) -> bool { + (*self as u8).eq(&(*other as u8)) + } +} + +impl PartialOrd for MetricLevel { + fn partial_cmp(&self, other: &Self) -> Option { + (*self as u8).partial_cmp(&(*other as u8)) + } +} diff --git a/src/common/src/monitor/connection.rs b/src/common/metrics/src/monitor/connection.rs similarity index 99% rename from src/common/src/monitor/connection.rs rename to src/common/metrics/src/monitor/connection.rs index 2e28102bf5077..13461dde90a23 100644 --- a/src/common/src/monitor/connection.rs +++ b/src/common/metrics/src/monitor/connection.rs @@ -38,9 +38,8 @@ use tokio::io::{AsyncRead, AsyncWrite, ReadBuf}; use tonic::transport::{Channel, Endpoint}; use tracing::{debug, info, warn}; -use crate::metrics::LabelGuardedIntCounterVec; use crate::monitor::GLOBAL_METRICS_REGISTRY; -use crate::register_guarded_int_counter_vec_with_registry; +use crate::{register_guarded_int_counter_vec_with_registry, LabelGuardedIntCounterVec}; pub trait MonitorAsyncReadWrite { fn on_read(&mut self, _size: usize) {} diff --git a/src/common/src/monitor/mod.rs b/src/common/metrics/src/monitor/mod.rs similarity index 100% rename from src/common/src/monitor/mod.rs rename to src/common/metrics/src/monitor/mod.rs diff --git a/src/common/src/monitor/my_stats.rs b/src/common/metrics/src/monitor/my_stats.rs similarity index 99% rename from src/common/src/monitor/my_stats.rs rename to src/common/metrics/src/monitor/my_stats.rs index e9d8cd4782e58..52c71167f2f97 100644 --- a/src/common/src/monitor/my_stats.rs +++ b/src/common/metrics/src/monitor/my_stats.rs @@ -16,8 +16,7 @@ use std::fmt::{Display, Formatter}; use itertools::Itertools; use prometheus::proto::Histogram; - -use crate::util::iter_util::ZipEqFast; +use rw_iter_util::ZipEqFast; #[derive(Clone, Default, Debug)] pub struct MyHistogram { diff --git a/src/common/src/monitor/process.rs b/src/common/metrics/src/monitor/process.rs similarity index 96% rename from src/common/src/monitor/process.rs rename to src/common/metrics/src/monitor/process.rs index c59e78bfa23ad..85a3cdf821e2c 100644 --- a/src/common/src/monitor/process.rs +++ b/src/common/metrics/src/monitor/process.rs @@ -17,7 +17,6 @@ use prometheus::{proto, IntCounter, IntGauge, Opts, Registry}; #[cfg(target_os = "linux")] use super::{CLOCK_TICK, PAGESIZE}; -use crate::util::resource_util; /// Monitors current process. pub fn monitor_process(registry: &Registry) { @@ -115,7 +114,7 @@ impl Collector for ProcessCollector { }; self.cpu_core_num - .set(resource_util::cpu::total_cpu_available() as i64); + .set(rw_resource_util::cpu::total_cpu_available() as i64); // collect MetricFamilies. let mut mfs = Vec::with_capacity(4); @@ -166,7 +165,7 @@ impl Collector for ProcessCollector { }; self.cpu_core_num - .set(resource_util::cpu::total_cpu_available() as i64); + .set(rw_resource_util::cpu::total_cpu_available() as i64); // collect MetricFamilies. let mut mfs = Vec::with_capacity(4); @@ -196,7 +195,7 @@ impl Collector for ProcessCollector { }; self.cpu_core_num - .set(resource_util::cpu::total_cpu_available() as i64); + .set(rw_resource_util::cpu::total_cpu_available() as i64); // collect MetricFamilies. let mut mfs = Vec::with_capacity(4); diff --git a/src/common/src/monitor/rwlock.rs b/src/common/metrics/src/monitor/rwlock.rs similarity index 100% rename from src/common/src/monitor/rwlock.rs rename to src/common/metrics/src/monitor/rwlock.rs diff --git a/src/common/src/metrics/relabeled_metric.rs b/src/common/metrics/src/relabeled_metric.rs similarity index 98% rename from src/common/src/metrics/relabeled_metric.rs rename to src/common/metrics/src/relabeled_metric.rs index 13ecc6eaacc40..1b4b4e8aaa038 100644 --- a/src/common/src/metrics/relabeled_metric.rs +++ b/src/common/metrics/src/relabeled_metric.rs @@ -15,9 +15,9 @@ use prometheus::core::{MetricVec, MetricVecBuilder}; use prometheus::{HistogramVec, IntCounterVec}; -use crate::config::MetricLevel; -use crate::metrics::{ +use crate::{ LabelGuardedHistogramVec, LabelGuardedIntCounterVec, LabelGuardedMetric, LabelGuardedMetricVec, + MetricLevel, }; /// For all `Relabeled*Vec` below, diff --git a/src/common/src/config.rs b/src/common/src/config.rs index 34345f36df217..01d5b07e6c27b 100644 --- a/src/common/src/config.rs +++ b/src/common/src/config.rs @@ -17,7 +17,6 @@ //! [`RwConfig`] corresponds to the whole config file and each other config struct corresponds to a //! section in `risingwave.toml`. -use std::cmp::Ordering; use std::collections::BTreeMap; use std::fs; use std::num::NonZeroUsize; @@ -531,41 +530,7 @@ pub struct StreamingConfig { pub unrecognized: Unrecognized, } -#[derive(Debug, Default, Clone, Copy, Serialize, Deserialize)] -pub enum MetricLevel { - #[default] - Disabled = 0, - Critical = 1, - Info = 2, - Debug = 3, -} - -impl clap::ValueEnum for MetricLevel { - fn value_variants<'a>() -> &'a [Self] { - &[Self::Disabled, Self::Critical, Self::Info, Self::Debug] - } - - fn to_possible_value<'a>(&self) -> ::std::option::Option { - match self { - Self::Disabled => Some(clap::builder::PossibleValue::new("disabled").alias("0")), - Self::Critical => Some(clap::builder::PossibleValue::new("critical")), - Self::Info => Some(clap::builder::PossibleValue::new("info").alias("1")), - Self::Debug => Some(clap::builder::PossibleValue::new("debug")), - } - } -} - -impl PartialEq for MetricLevel { - fn eq(&self, other: &Self) -> bool { - (*self as u8).eq(&(*other as u8)) - } -} - -impl PartialOrd for MetricLevel { - fn partial_cmp(&self, other: &Self) -> Option { - (*self as u8).partial_cmp(&(*other as u8)) - } -} +pub use risingwave_common_metrics::MetricLevel; /// The section `[storage]` in `risingwave.toml`. #[derive(Clone, Debug, Serialize, Deserialize, DefaultFromSerde, ConfigDoc)] diff --git a/src/common/src/lib.rs b/src/common/src/lib.rs index 860c3ed03e649..dc13a39eb6956 100644 --- a/src/common/src/lib.rs +++ b/src/common/src/lib.rs @@ -77,8 +77,12 @@ pub mod field_generator; pub mod hash; pub mod log; pub mod memory; -pub mod metrics; -pub mod monitor; +pub use risingwave_common_metrics as metrics; +pub use risingwave_common_metrics::{ + monitor, register_guarded_gauge_vec_with_registry, + register_guarded_histogram_vec_with_registry, register_guarded_int_counter_vec_with_registry, + register_guarded_int_gauge_vec_with_registry, +}; pub mod opts; pub mod range; pub mod row; diff --git a/src/common/src/util/mod.rs b/src/common/src/util/mod.rs index abe05fd27bfad..bb64f5a58c802 100644 --- a/src/common/src/util/mod.rs +++ b/src/common/src/util/mod.rs @@ -22,14 +22,14 @@ pub mod deployment; pub mod env_var; pub mod epoch; pub mod hash_util; -pub mod iter_util; +pub use rw_iter_util as iter_util; pub mod memcmp_encoding; pub mod meta_addr; pub mod panic; pub mod pretty_bytes; pub mod prost; pub mod query_log; -pub mod resource_util; +pub use rw_resource_util as resource_util; pub mod row_id; pub mod row_serde; pub mod runtime; diff --git a/src/utils/iter_util/Cargo.toml b/src/utils/iter_util/Cargo.toml new file mode 100644 index 0000000000000..e87a3ec355ece --- /dev/null +++ b/src/utils/iter_util/Cargo.toml @@ -0,0 +1,18 @@ +[package] +name = "rw_iter_util" +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[package.metadata.cargo-machete] +ignored = ["workspace-hack"] + +[package.metadata.cargo-udeps.ignore] +normal = ["workspace-hack"] + +[dependencies] +itertools = "0.12" + +[lints] +workspace = true diff --git a/src/common/src/util/iter_util.rs b/src/utils/iter_util/src/lib.rs similarity index 98% rename from src/common/src/util/iter_util.rs rename to src/utils/iter_util/src/lib.rs index 92f19a0ee46fc..58758c64a1ce5 100644 --- a/src/common/src/util/iter_util.rs +++ b/src/utils/iter_util/src/lib.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +#![feature(lint_reasons)] + pub trait ZipEqFast: ExactSizeIterator + Sized where B::IntoIter: ExactSizeIterator, diff --git a/src/utils/resource_util/Cargo.toml b/src/utils/resource_util/Cargo.toml new file mode 100644 index 0000000000000..288a8cbc72c39 --- /dev/null +++ b/src/utils/resource_util/Cargo.toml @@ -0,0 +1,24 @@ +[package] +name = "rw_resource_util" +edition = { workspace = true } +license = { workspace = true } +repository = { workspace = true } +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[package.metadata.cargo-machete] +ignored = ["workspace-hack"] + +[package.metadata.cargo-udeps.ignore] +normal = ["workspace-hack"] + +[dependencies] +fs-err = "2" +sysinfo = { version = "0.30", default-features = false } +thiserror-ext = { workspace = true } +tracing = "0.1" + +[dev-dependencies] +tempfile = "3" + +[lints] +workspace = true diff --git a/src/common/src/util/resource_util.rs b/src/utils/resource_util/src/lib.rs similarity index 99% rename from src/common/src/util/resource_util.rs rename to src/utils/resource_util/src/lib.rs index 424e65b2ee56b..4dcb23d477d5e 100644 --- a/src/common/src/util/resource_util.rs +++ b/src/utils/resource_util/src/lib.rs @@ -399,12 +399,10 @@ mod util { use std::io::prelude::*; use std::thread; - use tempfile; - use super::*; - use crate::util::resource_util::cpu::{self, get_system_cpu}; - use crate::util::resource_util::memory::get_system_memory; - use crate::util::resource_util::{Controller, DEFAULT_CGROUP_MAX_INDICATOR}; + use crate::cpu::{self, get_system_cpu}; + use crate::memory::get_system_memory; + use crate::{Controller, DEFAULT_CGROUP_MAX_INDICATOR}; const DEFAULT_NON_EXISTENT_PATH: &str = "default-non-existent-path"; #[test]