@@ -355,7 +355,8 @@ func TestBuckets(t *testing.T) {
355
355
}
356
356
357
357
got = ExponentialBucketsRange (1 , 100 , 10 )
358
- want = []float64 {1.0 , 1.6681005372000588 , 2.782559402207125 ,
358
+ want = []float64 {
359
+ 1.0 , 1.6681005372000588 , 2.782559402207125 ,
359
360
4.641588833612779 , 7.742636826811273 , 12.915496650148842 ,
360
361
21.544346900318846 , 35.93813663804629 , 59.94842503189414 ,
361
362
100.00000000000007 ,
@@ -469,7 +470,6 @@ func TestHistogramExemplar(t *testing.T) {
469
470
}
470
471
471
472
func TestSparseHistogram (t * testing.T ) {
472
-
473
473
scenarios := []struct {
474
474
name string
475
475
observations []float64 // With simulated interval of 1m.
@@ -498,6 +498,27 @@ func TestSparseHistogram(t *testing.T) {
498
498
factor : 1.2 ,
499
499
want : `sample_count:6 sample_sum:7.4 sb_schema:2 sb_zero_threshold:2.938735877055719e-39 sb_zero_count:1 sb_positive:<span:<offset:0 length:5 > delta:1 delta:-1 delta:2 delta:-2 delta:2 > ` ,
500
500
},
501
+ {
502
+ name : "factor 4 results in schema -1" ,
503
+ observations : []float64 {
504
+ 0.5 , 1 , // Bucket 0: (0.25, 1]
505
+ 1.5 , 2 , 3 , 3.5 , // Bucket 1: (1, 4]
506
+ 5 , 6 , 7 , // Bucket 2: (4, 16]
507
+ 33.33 , // Bucket 3: (16, 64]
508
+ },
509
+ factor : 4 ,
510
+ want : `sample_count:10 sample_sum:62.83 sb_schema:-1 sb_zero_threshold:2.938735877055719e-39 sb_zero_count:0 sb_positive:<span:<offset:0 length:4 > delta:2 delta:2 delta:-1 delta:-2 > ` ,
511
+ },
512
+ {
513
+ name : "factor 17 results in schema -2" ,
514
+ observations : []float64 {
515
+ 0.5 , 1 , // Bucket 0: (0.0625, 1]
516
+ 1.5 , 2 , 3 , 3.5 , 5 , 6 , 7 , // Bucket 1: (1, 16]
517
+ 33.33 , // Bucket 2: (16, 256]
518
+ },
519
+ factor : 17 ,
520
+ want : `sample_count:10 sample_sum:62.83 sb_schema:-2 sb_zero_threshold:2.938735877055719e-39 sb_zero_count:0 sb_positive:<span:<offset:0 length:3 > delta:2 delta:5 delta:-6 > ` ,
521
+ },
501
522
{
502
523
name : "negative buckets" ,
503
524
observations : []float64 {0 , - 1 , - 1.2 , - 1.4 , - 1.8 , - 2 },
@@ -662,7 +683,6 @@ func TestSparseHistogram(t *testing.T) {
662
683
}
663
684
})
664
685
}
665
-
666
686
}
667
687
668
688
func TestSparseHistogramConcurrency (t * testing.T ) {
0 commit comments