Skip to content

Commit

Permalink
fix: histogram tag column
Browse files Browse the repository at this point in the history
  • Loading branch information
sunng87 committed Aug 30, 2023
1 parent 8104bd9 commit 14ed071
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/servers/src/otlp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,23 +259,23 @@ fn encode_histogram(
let mut count_lines = LinesWriter::with_lines(data_points_len);

for data_point in &hist.data_points {
write_tags_and_timestamp(
&mut bucket_lines,
resource_attrs,
scope_attrs,
Some(data_point.attributes.as_ref()),
data_point.time_unix_nano as i64,
)?;

for (idx, count) in data_point.bucket_counts.iter().enumerate() {
write_tags_and_timestamp(
&mut bucket_lines,
resource_attrs,
scope_attrs,
Some(data_point.attributes.as_ref()),
data_point.time_unix_nano as i64,
)?;

if let Some(upper_bounds) = data_point.explicit_bounds.get(idx) {
bucket_lines
.write_f64(HISTOGRAM_LE_COLUMN, *upper_bounds)
.write_tag(HISTOGRAM_LE_COLUMN, &upper_bounds.to_string())
.context(error::OtlpMetricsWriteSnafu)?;
} else if idx == data_point.explicit_bounds.len() {
// The last bucket
bucket_lines
.write_f64(HISTOGRAM_LE_COLUMN, f64::INFINITY)
.write_tag(HISTOGRAM_LE_COLUMN, &f64::INFINITY.to_string())
.context(error::OtlpMetricsWriteSnafu)?;
}

Expand Down

0 comments on commit 14ed071

Please sign in to comment.