Skip to content

Replace SendEncodeMetric with SendSyncEncodeMetric #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2022
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
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.16.0] - unreleased

### Changed

- Require `Registry` default generic type `SendEncodeMetric` to be `Sync`. See [PR 58].

[PR 58]: https://github.com/prometheus/client_rust/pull/58

## [0.15.1] - 2022-02-04

### Added
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "prometheus-client"
version = "0.15.1"
version = "0.16.0"
authors = ["Max Inden <[email protected]>"]
edition = "2018"
description = "Open Metrics client library allowing users to natively instrument applications."
Expand Down
6 changes: 3 additions & 3 deletions src/encoding/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,11 +404,11 @@ impl EncodeMetric for Box<dyn EncodeMetric> {
}
}

pub trait SendEncodeMetric: EncodeMetric + Send {}
pub trait SendSyncEncodeMetric: EncodeMetric + Send + Sync {}

impl<T: EncodeMetric + Send> SendEncodeMetric for T {}
impl<T: EncodeMetric + Send + Sync> SendSyncEncodeMetric for T {}

impl EncodeMetric for Box<dyn SendEncodeMetric> {
impl EncodeMetric for Box<dyn SendSyncEncodeMetric> {
fn encode(&self, encoder: Encoder) -> Result<(), std::io::Error> {
self.deref().encode(encoder)
}
Expand Down
2 changes: 1 addition & 1 deletion src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ use std::ops::Add;
/// # "# EOF\n";
/// # assert_eq!(expected, String::from_utf8(buffer).unwrap());
/// ```
pub struct Registry<M = Box<dyn crate::encoding::text::SendEncodeMetric>> {
pub struct Registry<M = Box<dyn crate::encoding::text::SendSyncEncodeMetric>> {
prefix: Option<Prefix>,
labels: Vec<(Cow<'static, str>, Cow<'static, str>)>,
metrics: Vec<(Descriptor, M)>,
Expand Down