Skip to content

Commit

Permalink
src/registry.rs: Add with_prefix to Registry (prometheus#70)
Browse files Browse the repository at this point in the history
Signed-off-by: Victor Nordam Suadicani <v.n.suadicani@gmail.com>
Signed-off-by: ackintosh <sora.akatsuki@gmail.com>
  • Loading branch information
Victor-N-Suadicani authored and ackintosh committed Aug 27, 2022
1 parent 496c8ab commit 42d1534
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.md
Expand Up @@ -7,15 +7,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [0.17.0] - unreleased

### Changed

- Updates to Rust 2021 Edition. See [PR 65].

### Removed
### Added
- Added a `with_prefix` method to `Registry` to allow initializing a registry with a prefix. See [PR 70].

### Removed
- Remove `Add` trait implementation for a private type which lead to compile time conflicts with existing `Add` implementations e.g. on `String`. See [PR 69].

[PR 65]: https://github.com/prometheus/client_rust/pull/65
[PR 69]: https://github.com/prometheus/client_rust/pull/69
[PR 70]: https://github.com/prometheus/client_rust/pull/70

## [0.16.0]

Expand Down
8 changes: 8 additions & 0 deletions src/registry.rs
Expand Up @@ -76,6 +76,14 @@ impl<M> Default for Registry<M> {
}

impl<M> Registry<M> {
/// Creates a new default [`Registry`] with the given prefix.
pub fn with_prefix(prefix: impl Into<String>) -> Self {
Self {
prefix: Some(Prefix(prefix.into())),
..Default::default()
}
}

/// Register a metric with the [`Registry`].
///
/// Note: In the Open Metrics text exposition format some metric types have
Expand Down

0 comments on commit 42d1534

Please sign in to comment.