Skip to content

Commit

Permalink
correct counter type metric, avoid empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
Keksoj committed Oct 20, 2023
1 parent 1edd1ca commit 5b0412b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/svc/telemetry/prometheus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ fn create_metric_lines(
filtered_metric: &FilteredMetrics,
) -> String {
let mut lines = String::new();
// skip percentiles entirely to avoid newlines
if matches!(filtered_metric.inner, Some(Inner::Percentiles(_))) {
return lines;
}

let metric_name = replace_dots_with_underscores(metric_name);
let type_line = create_type_line(&metric_name, filtered_metric);
let metric_lines = match &filtered_metric.inner {
Expand Down Expand Up @@ -181,7 +186,7 @@ fn get_metric_type(filtered_metric: &FilteredMetrics) -> String {
match &filtered_metric.inner {
Some(inner) => match inner {
Inner::Gauge(_) => "gauge".to_string(),
Inner::Count(_) => "count".to_string(),
Inner::Count(_) => "counter".to_string(),
Inner::Time(_) => "time".to_string(),
Inner::Percentiles(_) => "histogram".to_string(),
Inner::TimeSerie(_) => "time series".to_string(),
Expand All @@ -195,8 +200,8 @@ fn get_metric_type(filtered_metric: &FilteredMetrics) -> String {
#[tracing::instrument(skip_all)]
fn create_type_line(name: &str, filtered_metric: &FilteredMetrics) -> String {
// temporary fix to skip conversion of percentiles
if matches!(filtered_metric.inner,Some(Inner::Percentiles(_))) {
return String::new()
if matches!(filtered_metric.inner, Some(Inner::Percentiles(_))) {
return String::new();
}
format!("# TYPE {} {}", name, get_metric_type(filtered_metric))
}
Expand Down

0 comments on commit 5b0412b

Please sign in to comment.