From b239b7160f458faa181d57c7dd47c0d3979ae737 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Tue, 22 Jul 2025 19:19:45 +0800 Subject: [PATCH 1/2] feat: impl Collector for std::sync::Arc Signed-off-by: hanabi1224 --- src/collector.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/collector.rs b/src/collector.rs index 66270c41..eea9d866 100644 --- a/src/collector.rs +++ b/src/collector.rs @@ -39,3 +39,9 @@ pub trait Collector: std::fmt::Debug + Send + Sync + 'static { /// Once the [`Collector`] is registered, this method is called on each scrape. fn encode(&self, encoder: DescriptorEncoder) -> Result<(), std::fmt::Error>; } + +impl Collector for std::sync::Arc { + fn encode(&self, encoder: DescriptorEncoder) -> Result<(), std::fmt::Error> { + self.as_ref().encode(encoder) + } +} From 76d7b3079cee55c645f7403738c7c309a944bce2 Mon Sep 17 00:00:00 2001 From: hanabi1224 Date: Tue, 22 Jul 2025 19:23:16 +0800 Subject: [PATCH 2/2] changelog Signed-off-by: hanabi1224 --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c798c594..006d53b4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,9 +14,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `Family::get_or_create_owned` can access a metric in a labeled family. This method avoids the risk of runtime deadlocks at the expense of creating an owned type. See [PR 244]. + +- `impl Collector for std::sync::Arc`. + See [PR 273]. [PR 244]: https://github.com/prometheus/client_rust/pull/244 [PR 257]: https://github.com/prometheus/client_rust/pull/257 +[PR 273]: https://github.com/prometheus/client_rust/pull/273 ### Changed