diff --git a/CHANGELOG.md b/CHANGELOG.md index c798c59..006d53b 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 diff --git a/src/collector.rs b/src/collector.rs index 66270c4..eea9d86 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) + } +}