From a7eb4b9b2a4b248f119b4066edc4cea47dde4c6e Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Tue, 2 Sep 2025 00:00:00 +0000 Subject: [PATCH] feat: introduce `test-util` feature flag for background, see discussion in #242: > > Would you be amenable to feature-gating these public helpers behind > > a `test-util` feature? This is a pretty common approach we've seen > > in other crates. > > That sounds reasonable to me. Contribution welcome. Thanks. Please > point out very prominently that we might break any of those APIs in > a patch release. \- this commit introduces a `test-util` feature flag. this feature flag will function as a gate for additional interfaces, such as accessors to read the value of a histogram, that facilitate integration tests inspecting metrics. comments note that any forthcoming interfaces included by this feature are not subject to stability guarantees. Signed-off-by: katelyn martin --- Cargo.toml | 6 ++++++ src/lib.rs | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index a35d1457..26356dd5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,6 +14,12 @@ documentation = "https://docs.rs/prometheus-client" default = [] protobuf = ["dep:prost", "dep:prost-types", "dep:prost-build"] +# This feature provides additional interfaces for testing. +# +# NB: Interfaces gated by this feature flag are not subject to stability +# guarantees and may be changed or removed in patch releases. +test-util = [] + [workspace] members = ["derive-encode"] diff --git a/src/lib.rs b/src/lib.rs index cfff6238..9d2bf3a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,6 +77,12 @@ //! ``` //! See [examples] directory for more. //! +//! # Features +//! +//! The `test-util` gates additional interfaces, such as accessors, to facilitate integration and +//! unit testing of metrics. Note that interfaces gated by this feature flag are not subject to +//! stability guarantees and may be changed or removed in patch releases. +//! //! [examples]: https://github.com/prometheus/client_rust/tree/master/examples pub mod collector;