diff --git a/util/grpc/Cargo.toml b/util/grpc/Cargo.toml index 98166a8d95..b73cba75d8 100644 --- a/util/grpc/Cargo.toml +++ b/util/grpc/Cargo.toml @@ -11,7 +11,7 @@ rust-version = { workspace = true } [dependencies] mc-common = { path = "../../common", features = ["loggers"] } mc-util-build-info = { path = "../build/info" } -mc-util-metrics = { path = "../metrics" } +mc-util-metrics = { path = "../metrics", features = ["service_metrics"] } mc-util-serial = { path = "../serial", features = ["std"] } mc-util-uri = { path = "../uri" } diff --git a/util/metrics/Cargo.toml b/util/metrics/Cargo.toml index edc18672b7..7e4bbdf590 100644 --- a/util/metrics/Cargo.toml +++ b/util/metrics/Cargo.toml @@ -6,11 +6,15 @@ edition = "2021" license = "GPL-3.0" rust-version = { workspace = true } +[features] +default = [] +service_metrics = ["dep:grpcio"] + [dependencies] mc-common = { path = "../../common", features = ["log"] } chrono = "0.4" -grpcio = "0.13" +grpcio = { version = "0.13", optional = true } lazy_static = "1.4" prometheus = "0.13" protobuf = "2.27.1" diff --git a/util/metrics/src/lib.rs b/util/metrics/src/lib.rs index bf94ac94e3..6afc89f376 100644 --- a/util/metrics/src/lib.rs +++ b/util/metrics/src/lib.rs @@ -9,6 +9,7 @@ pub use serde_json::json; // ------------------------------------ mod json_encoder; mod op_counters; +#[cfg(feature = "service_metrics")] mod service_metrics; pub use json_encoder::JsonEncoder as MetricsJsonEncoder; @@ -19,4 +20,5 @@ pub use prometheus::{ register, register_histogram, Histogram, HistogramOpts, HistogramVec, IntCounter, IntCounterVec, IntGauge, IntGaugeVec, Opts, }; +#[cfg(feature = "service_metrics")] pub use service_metrics::{GrpcMethodName, ServiceMetrics};