@@ -925,7 +925,7 @@ def test_collect_results_cumulative(self):
925
925
self .assertEqual (collection_1 .min , 0.045 )
926
926
self .assertEqual (collection_1 .max , 8 )
927
927
928
- def test_merge_collect (self ):
928
+ def test_merge_collect_cumulative (self ):
929
929
exponential_histogram_aggregation = (
930
930
_ExponentialBucketHistogramAggregation (Mock (), Mock (), max_size = 4 )
931
931
)
@@ -965,3 +965,44 @@ def test_merge_collect(self):
965
965
)
966
966
967
967
self .assertEqual (result .scale , result_1 .scale )
968
+
969
+ def test_merge_collect_delta (self ):
970
+ exponential_histogram_aggregation = (
971
+ _ExponentialBucketHistogramAggregation (Mock (), Mock (), max_size = 4 )
972
+ )
973
+
974
+ for value in [2 , 4 , 8 , 16 ]:
975
+ exponential_histogram_aggregation .aggregate (
976
+ Measurement (value , Mock ())
977
+ )
978
+
979
+ self .assertEqual (exponential_histogram_aggregation ._mapping .scale , 0 )
980
+ self .assertEqual (exponential_histogram_aggregation ._positive .offset , 0 )
981
+ self .assertEqual (
982
+ exponential_histogram_aggregation ._positive .counts , [1 , 1 , 1 , 1 ]
983
+ )
984
+
985
+ result = exponential_histogram_aggregation .collect (
986
+ AggregationTemporality .DELTA ,
987
+ 0 ,
988
+ )
989
+
990
+ for value in [1 , 2 , 4 , 8 ]:
991
+ exponential_histogram_aggregation .aggregate (
992
+ Measurement (1 / value , Mock ())
993
+ )
994
+
995
+ self .assertEqual (exponential_histogram_aggregation ._mapping .scale , 0 )
996
+ self .assertEqual (
997
+ exponential_histogram_aggregation ._positive .offset , - 4
998
+ )
999
+ self .assertEqual (
1000
+ exponential_histogram_aggregation ._positive .counts , [1 , 1 , 1 , 1 ]
1001
+ )
1002
+
1003
+ result_1 = exponential_histogram_aggregation .collect (
1004
+ AggregationTemporality .DELTA ,
1005
+ 0 ,
1006
+ )
1007
+
1008
+ self .assertEqual (result .scale , result_1 .scale )
0 commit comments