Skip to content

Commit

Permalink
Upgrade to openmetrics parser 0.4.1
Browse files Browse the repository at this point in the history
This contains a fix for #17, allowing empty metric sets to be parsed

Signed-off-by: sinkingpoint <colin@quirl.co.nz>
  • Loading branch information
sinkingpoint committed May 15, 2023
1 parent 635006f commit bda3f24
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ keywords = ["openmetrics", "prometheus", "pushgateway"]
[dependencies]
tokio = { version = "1", features = ["full"] }
warp = "0.3"
openmetrics-parser = "0.4.0"
openmetrics-parser = "0.4.1"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
clap = "2.33.3"
Expand Down
16 changes: 16 additions & 0 deletions src/aggregator_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,19 @@ async fn test_push_with_different_label_names() {
assert!(agg.parse_and_merge("requests_num_total2{clearmode=\"mean5m\"} 1\n", &HashMap::new()).await.is_ok(), "failed to add metric with clearmode");
assert!(agg.parse_and_merge("requests_num_total2{clearmode=\"mean5m\"} 1\n", &HashMap::new()).await.is_ok(), "failed to add second metric with clearmode");
}

#[tokio::test]
async fn test_17() {
let mut agg = Aggregator::new();
let result = agg.parse_and_merge("# HELP metric_without_values_total This metric does not always have values
# TYPE metric_without_values_total counter
# HELP metric_with_values_total This metric will always have values
# TYPE metric_with_values_total counter
metric_with_values_total{a_label=\"label_value\",another_label=\"a_value\"} 1.0
# HELP metric_with_values_created This metric will always have values
# TYPE metric_with_values_created gauge
metric_with_values_created{a_label=\"label_value\",another_label=\"a_value\"} 1.665577650707084e+09
", &HashMap::new()).await;

assert!(result.is_ok(), "failed to parse valid metric: {:?}", result.err());
}

0 comments on commit bda3f24

Please sign in to comment.