@@ -214,11 +214,12 @@ datapoint(#histogram_datapoint{} = DP, MetricName, AddCreated, ScopeLabels, [Poi
214
214
false -> []
215
215
end ,
216
216
217
- Buckets = lists :map (
218
- fun ({C , Le }) ->
217
+ { Buckets , _ } = lists :mapfoldl (
218
+ fun ({C , Le }, Sum ) ->
219
219
HistoLabels = surround_labels (join_labels (Labels , render_label_pair ({" le" , Le }))),
220
- [MetricName , " _bucket" , HistoLabels , " " , number_to_binary (C ), " \n " ]
220
+ { [MetricName , " _bucket" , HistoLabels , " " , number_to_binary (Sum + C ), " \n " ], Sum + C }
221
221
end ,
222
+ 0 ,
222
223
lists :zip (DP # histogram_datapoint .bucket_counts , DP # histogram_datapoint .explicit_bounds ++ [<<" +Inf" >>])
223
224
),
224
225
@@ -524,8 +525,8 @@ monotonic_histogram_test() ->
524
525
" # UNIT test_sec sec" ,
525
526
" # HELP test_sec lorem ipsum" ,
526
527
" test_sec_bucket{otel_scope_name=\" scope-1\" ,otel_scope_version=\" version-1\" ,le=\" 2\" } 2" ,
527
- " test_sec_bucket{otel_scope_name=\" scope-1\" ,otel_scope_version=\" version-1\" ,le=\" 3\" } 0 " ,
528
- " test_sec_bucket{otel_scope_name=\" scope-1\" ,otel_scope_version=\" version-1\" ,le=\" +Inf\" } 1 " ,
528
+ " test_sec_bucket{otel_scope_name=\" scope-1\" ,otel_scope_version=\" version-1\" ,le=\" 3\" } 2 " ,
529
+ " test_sec_bucket{otel_scope_name=\" scope-1\" ,otel_scope_version=\" version-1\" ,le=\" +Inf\" } 3 " ,
529
530
" test_sec_count{otel_scope_name=\" scope-1\" ,otel_scope_version=\" version-1\" } 3" ,
530
531
" test_sec_sum{otel_scope_name=\" scope-1\" ,otel_scope_version=\" version-1\" } 7" ,
531
532
" test_sec_created{otel_scope_name=\" scope-1\" ,otel_scope_version=\" version-1\" } 0" ,
0 commit comments