Skip to content

Commit fde7e85

Browse files
committed
actually export LabelSet so it can be used with formatting methods
1 parent 51fbc50 commit fde7e85

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

metrics-exporter-prometheus/src/common.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ pub enum BuildError {
8383
/// Represents a set of labels as structured key-value pairs
8484
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
8585
pub struct LabelSet {
86-
pub labels: Vec<(String, String)>,
86+
labels: Vec<(String, String)>,
8787
}
8888

8989
impl LabelSet {
90+
/// Creates a new `LabelSet` from the given key and a set of global labels.
9091
pub fn from_key_and_global(
9192
key: &metrics::Key,
9293
global_labels: &IndexMap<String, String>,
@@ -98,10 +99,12 @@ impl LabelSet {
9899
Self { labels: labels.into_iter().collect() }
99100
}
100101

102+
/// Returns `true` if the label set is empty.
101103
pub fn is_empty(&self) -> bool {
102104
self.labels.is_empty()
103105
}
104106

107+
/// Returns an iterator that yields the labels in a sanitized and concatenated format.
105108
pub fn to_strings(&self) -> impl Iterator<Item = String> + '_ {
106109
self.labels.iter().map(|(k, v)| {
107110
format!(

metrics-exporter-prometheus/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
#![deny(missing_docs)]
120120
#![cfg_attr(docsrs, feature(doc_cfg), deny(rustdoc::broken_intra_doc_links))]
121121
mod common;
122-
pub use self::common::{BuildError, Matcher};
122+
pub use self::common::{BuildError, LabelSet, Matcher};
123123

124124
mod distribution;
125125
pub use distribution::{Distribution, DistributionBuilder};

0 commit comments

Comments
 (0)