@@ -71,19 +71,19 @@ fn families_to_json_events(families: &[MetricFamily]) -> Vec<VectorEvent<'_>> {
71
71
// We need to convert from cumulative counts (used by the Prometheus library)
72
72
// to plain counts (used by Vector).
73
73
let mut buckets = Vec :: new ( ) ;
74
+ let mut counts = Vec :: new ( ) ;
74
75
let mut last_cumulative_count = 0 ;
75
76
for bucket in histogram. get_bucket ( ) {
76
- buckets. push ( VectorHistogramBucket {
77
- upper_limit : bucket. get_upper_bound ( ) ,
78
- count : bucket. get_cumulative_count ( ) - last_cumulative_count,
79
- } ) ;
77
+ buckets. push ( bucket. get_upper_bound ( ) ) ;
78
+ counts. push ( bucket. get_cumulative_count ( ) - last_cumulative_count) ;
80
79
last_cumulative_count = bucket. get_cumulative_count ( ) ;
81
80
}
82
81
83
82
VectorMetricData :: AggregatedHistogram {
84
83
count : histogram. get_sample_count ( ) ,
85
84
sum : histogram. get_sample_sum ( ) ,
86
85
buckets,
86
+ counts,
87
87
}
88
88
}
89
89
other => {
@@ -191,7 +191,8 @@ struct VectorMetric<'a> {
191
191
#[ serde( rename_all = "snake_case" ) ]
192
192
enum VectorMetricData {
193
193
AggregatedHistogram {
194
- buckets : Vec < VectorHistogramBucket > ,
194
+ buckets : Vec < f64 > ,
195
+ counts : Vec < u64 > ,
195
196
count : u64 ,
196
197
sum : f64 ,
197
198
} ,
@@ -203,12 +204,6 @@ enum VectorMetricData {
203
204
} ,
204
205
}
205
206
206
- #[ derive( Serialize , Debug , PartialEq ) ]
207
- struct VectorHistogramBucket {
208
- upper_limit : f64 ,
209
- count : u64 ,
210
- }
211
-
212
207
#[ cfg( test) ]
213
208
mod tests {
214
209
use super :: * ;
@@ -304,51 +299,9 @@ mod tests {
304
299
metric: VectorMetric {
305
300
data: VectorMetricData :: AggregatedHistogram {
306
301
buckets: vec![
307
- VectorHistogramBucket {
308
- upper_limit: 0.005 ,
309
- count: 6 ,
310
- } ,
311
- VectorHistogramBucket {
312
- upper_limit: 0.01 ,
313
- count: 4 ,
314
- } ,
315
- VectorHistogramBucket {
316
- upper_limit: 0.025 ,
317
- count: 15 ,
318
- } ,
319
- VectorHistogramBucket {
320
- upper_limit: 0.05 ,
321
- count: 25 ,
322
- } ,
323
- VectorHistogramBucket {
324
- upper_limit: 0.1 ,
325
- count: 50 ,
326
- } ,
327
- VectorHistogramBucket {
328
- upper_limit: 0.25 ,
329
- count: 150 ,
330
- } ,
331
- VectorHistogramBucket {
332
- upper_limit: 0.5 ,
333
- count: 250 ,
334
- } ,
335
- VectorHistogramBucket {
336
- upper_limit: 1.0 ,
337
- count: 500 ,
338
- } ,
339
- VectorHistogramBucket {
340
- upper_limit: 2.5 ,
341
- count: 1501 ,
342
- } ,
343
- VectorHistogramBucket {
344
- upper_limit: 5.0 ,
345
- count: 2499 ,
346
- } ,
347
- VectorHistogramBucket {
348
- upper_limit: 10.0 ,
349
- count: 5001 ,
350
- } ,
302
+ 0.005 , 0.01 , 0.025 , 0.05 , 0.1 , 0.25 , 0.5 , 1.0 , 2.5 , 5.0 , 10.0 ,
351
303
] ,
304
+ counts: vec![ 6 , 4 , 15 , 25 , 50 , 150 , 250 , 500 , 1501 , 2499 , 5001 , ] ,
352
305
count: 11001 ,
353
306
sum: 60505.50000000138 ,
354
307
} ,
0 commit comments