Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Collector> Collector for std::sync::Arc<T>`.
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

Expand Down
6 changes: 6 additions & 0 deletions src/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<T: Collector> Collector for std::sync::Arc<T> {
fn encode(&self, encoder: DescriptorEncoder) -> Result<(), std::fmt::Error> {
self.as_ref().encode(encoder)
}
}
Loading