Skip to content

Commit

Permalink
Print histogram bucket info in stdout exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
cijothomas committed Jan 28, 2025
1 parent 18834f5 commit c88fc95
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions opentelemetry-stdout/src/metrics/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,20 @@ fn print_hist_data_points<T: Debug>(data_points: &[HistogramDataPoint<T>]) {
for kv in data_point.attributes.iter() {
println!("\t\t\t\t -> {}: {}", kv.key, kv.value.as_str());
}

println!("\t\t\tBuckets");
let mut lower_bound = f64::NEG_INFINITY;
for (i, &upper_bound) in data_point.bounds.iter().enumerate() {
let count = data_point.bucket_counts.get(i).unwrap_or(&0);
println!("\t\t\t\t {} to {} : {}", lower_bound, upper_bound, count);
lower_bound = upper_bound;
}

Check warning on line 244 in opentelemetry-stdout/src/metrics/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-stdout/src/metrics/exporter.rs#L238-L244

Added lines #L238 - L244 were not covered by tests

let last_count = data_point
.bucket_counts
.get(data_point.bounds.len())
.unwrap_or(&0);
println!("\t\t\t\t{} to +Infinity : {}", lower_bound, last_count);

Check warning on line 250 in opentelemetry-stdout/src/metrics/exporter.rs

View check run for this annotation

Codecov / codecov/patch

opentelemetry-stdout/src/metrics/exporter.rs#L246-L250

Added lines #L246 - L250 were not covered by tests
}
}

Expand Down

0 comments on commit c88fc95

Please sign in to comment.