From a5ed4f2bfa8fc0a7a9cba4e3ca786c9d3e45978d Mon Sep 17 00:00:00 2001 From: Brandon Yarbrough Date: Tue, 20 Sep 2022 23:30:51 +0000 Subject: [PATCH 1/2] Add 'push-no-tls' feature, for push support when HTTPS is unnecessary. Signed-off-by: Brandon Yarbrough --- Cargo.toml | 7 +++++-- src/lib.rs | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index e2197605..52fca5e0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,10 @@ default = ["protobuf"] gen = ["protobuf-codegen-pure"] nightly = ["libc"] process = ["libc", "procfs"] -push = ["reqwest", "libc", "protobuf"] +push = ["push-reqwest-ssl", "push-deps"] +push-no-tls = ["push-deps"] +push-reqwest-ssl = ["reqwest?/default-tls"] +push-deps = ["reqwest", "libc", "protobuf"] [dependencies] cfg-if = "^1.0" @@ -32,7 +35,7 @@ libc = { version = "^0.2", optional = true } parking_lot = "^0.12" protobuf = { version = "^2.0", optional = true } memchr = "^2.3" -reqwest = { version = "^0.11", features = ["blocking"], optional = true } +reqwest = { version = "^0.11", default-features = false, features = ["blocking"], optional = true } thiserror = "^1.0" [target.'cfg(target_os = "linux")'.dependencies] diff --git a/src/lib.rs b/src/lib.rs index 7991d8ff..240a2946 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -158,7 +158,7 @@ mod errors; mod gauge; mod histogram; mod metrics; -#[cfg(feature = "push")] +#[cfg(feature = "push-deps")] mod push; mod registry; mod value; @@ -219,7 +219,7 @@ pub use self::histogram::DEFAULT_BUCKETS; pub use self::histogram::{exponential_buckets, linear_buckets}; pub use self::histogram::{Histogram, HistogramOpts, HistogramTimer, HistogramVec}; pub use self::metrics::Opts; -#[cfg(feature = "push")] +#[cfg(feature = "push-deps")] pub use self::push::{ hostname_grouping_key, push_add_collector, push_add_metrics, push_collector, push_metrics, BasicAuthentication, From 35e3328326c31ab28e7c92a1aa62e05db95e54a7 Mon Sep 17 00:00:00 2001 From: Brandon Yarbrough Date: Tue, 20 Sep 2022 23:38:25 +0000 Subject: [PATCH 2/2] Add documentation for feature. Signed-off-by: Brandon Yarbrough --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 47b862ba..777e2bf1 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,9 @@ This crate provides several optional components which can be enabled via [Cargo - `push`: Enable [push metrics](https://prometheus.io/docs/instrumenting/pushing/) support. +- `push-no-tls`: An alternative to `push`, which will not link in TLS libraries, disabling HTTPS support but resulting in a leaner build. + By default, the Pushgateway uses HTTP and not HTTPS. + ### Static Metric When using a `MetricVec` with label values known at compile time