Skip to content

Commit f1a4d16

Browse files
committed
src/encoding/text: Encode Info metric labels
1 parent 43671c3 commit f1a4d16

File tree

4 files changed

+9
-4
lines changed

4 files changed

+9
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,12 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7-
## [0.11.0] - 2021-06-08
7+
## [0.11.1] - 2021-06-08
8+
### Fixed
9+
- Encode Info metric labels.
810

11+
## [0.11.0] - 2021-06-08
12+
### Added
913
- Add support for OpenMetrics Info metrics (see [PR 18]).
1014

1115
[PR 18]: https://github.com/mxinden/rust-open-metrics-client/pull/18

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "open-metrics-client"
3-
version = "0.11.0"
3+
version = "0.11.1"
44
authors = ["Max Inden <mail@max-inden.de>"]
55
edition = "2018"
66
description = "Open Metrics client library allowing users to natively instrument applications."

src/encoding/text.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,7 @@ where
551551
{
552552
fn encode(&self, mut encoder: Encoder) -> Result<(), std::io::Error> {
553553
encoder
554+
.with_label_set(&self.0)
554555
.encode_suffix("info")?
555556
.no_bucket()?
556557
.encode_value(1u32)?
@@ -674,7 +675,7 @@ mod tests {
674675

675676
let expected = "# HELP my_info_metric My info metric.\n".to_owned()
676677
+ "# TYPE my_info_metric info\n"
677-
+ "my_info_metric_info 1\n"
678+
+ "my_info_metric_info{os=\"GNU/linux\"} 1\n"
678679
+ "# EOF\n";
679680
assert_eq!(expected, String::from_utf8(encoded.clone()).unwrap());
680681

src/metrics/info.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use crate::metrics::{MetricType, TypedMetric};
1212
///
1313
/// let _info = Info::new(vec![("os", "GNU/linux")]);
1414
/// ```
15-
pub struct Info<S>(S);
15+
pub struct Info<S>(pub(crate) S);
1616

1717
impl<S> Info<S> {
1818
pub fn new(label_set: S) -> Self {

0 commit comments

Comments
 (0)