From 46ccf4d0e5449a2cdc152873bb4802efd458f324 Mon Sep 17 00:00:00 2001 From: Ning Sun Date: Wed, 30 Aug 2023 15:08:27 +0800 Subject: [PATCH] fix: use accumulated count in buckets --- src/servers/src/otlp.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/servers/src/otlp.rs b/src/servers/src/otlp.rs index 3b5a88dc685a..d732a47d1a80 100644 --- a/src/servers/src/otlp.rs +++ b/src/servers/src/otlp.rs @@ -258,6 +258,7 @@ fn encode_histogram( let mut sum_lines = LinesWriter::with_lines(data_points_len); let mut count_lines = LinesWriter::with_lines(data_points_len); + let mut accumulated_count = 0; for data_point in &hist.data_points { for (idx, count) in data_point.bucket_counts.iter().enumerate() { write_tags_and_timestamp( @@ -279,8 +280,9 @@ fn encode_histogram( .context(error::OtlpMetricsWriteSnafu)?; } + accumulated_count += count; bucket_lines - .write_u64(GREPTIME_VALUE, *count) + .write_u64(GREPTIME_VALUE, accumulated_count) .context(error::OtlpMetricsWriteSnafu)?; bucket_lines.commit();