@@ -52,18 +52,18 @@ def generalized_reservoir_factory(
5252 size : int = 1 , boundaries : Sequence [float ] = None
5353) -> Callable [[Type [_Aggregation ]], ExemplarReservoirBuilder ]:
5454 def factory (
55- aggregationType : Type [_Aggregation ],
55+ aggregation_type : Type [_Aggregation ],
5656 ) -> ExemplarReservoirBuilder :
57- if issubclass (aggregationType , _ExplicitBucketHistogramAggregation ):
57+ if issubclass (aggregation_type , _ExplicitBucketHistogramAggregation ):
5858 return lambda ** kwargs : AlignedHistogramBucketExemplarReservoir (
5959 boundaries = boundaries or [],
6060 ** {k : v for k , v in kwargs .items () if k != "boundaries" },
6161 )
62- else :
63- return lambda ** kwargs : SimpleFixedSizeExemplarReservoir (
64- size = size ,
65- ** {k : v for k , v in kwargs .items () if k != "size" },
66- )
62+
63+ return lambda ** kwargs : SimpleFixedSizeExemplarReservoir (
64+ size = size ,
65+ ** {k : v for k , v in kwargs .items () if k != "size" },
66+ )
6767
6868 return factory
6969
@@ -288,7 +288,11 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
288288 # +1 call to _create_aggregation
289289 view_instrument_match .consume_measurement (
290290 Measurement (
291- value = 0 , instrument = instrument , attributes = {"foo" : "bar0" }
291+ value = 0 ,
292+ time_unix_nano = time_ns (),
293+ instrument = instrument ,
294+ attributes = {"foo" : "bar0" },
295+ context = Context (),
292296 )
293297 )
294298 view_instrument_match ._view ._aggregation ._create_aggregation .assert_called_with (
@@ -304,7 +308,11 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
304308 # +1 call to _create_aggregation
305309 view_instrument_match .consume_measurement (
306310 Measurement (
307- value = 0 , instrument = instrument , attributes = {"foo" : "bar1" }
311+ value = 0 ,
312+ time_unix_nano = time_ns (),
313+ instrument = instrument ,
314+ attributes = {"foo" : "bar1" },
315+ context = Context (),
308316 )
309317 )
310318 view_instrument_match ._view ._aggregation ._create_aggregation .assert_called_with (
@@ -322,7 +330,11 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
322330 # +1 call to create_aggregation
323331 view_instrument_match .consume_measurement (
324332 Measurement (
325- value = 0 , instrument = instrument , attributes = {"foo" : "bar" }
333+ value = 0 ,
334+ time_unix_nano = time_ns (),
335+ instrument = instrument ,
336+ attributes = {"foo" : "bar" },
337+ context = Context (),
326338 )
327339 )
328340 view_instrument_match ._view ._aggregation ._create_aggregation .assert_called_with (
@@ -331,12 +343,20 @@ def test_collect_resets_start_time_unix_nano(self, mock_time_ns):
331343 # No new calls to _create_aggregation because attributes remain the same
332344 view_instrument_match .consume_measurement (
333345 Measurement (
334- value = 0 , instrument = instrument , attributes = {"foo" : "bar" }
346+ value = 0 ,
347+ time_unix_nano = time_ns (),
348+ instrument = instrument ,
349+ attributes = {"foo" : "bar" },
350+ context = Context (),
335351 )
336352 )
337353 view_instrument_match .consume_measurement (
338354 Measurement (
339- value = 0 , instrument = instrument , attributes = {"foo" : "bar" }
355+ value = 0 ,
356+ time_unix_nano = time_ns (),
357+ instrument = instrument ,
358+ attributes = {"foo" : "bar" },
359+ context = Context (),
340360 )
341361 )
342362 # In total we have 5 calls for _create_aggregation
@@ -520,8 +540,8 @@ def test_consume_measurement_with_custom_reservoir_factory(self):
520540 )
521541 )
522542
523- data_points = view_instrument_match . collect (
524- AggregationTemporality .CUMULATIVE , 0
543+ data_points = list (
544+ view_instrument_match . collect ( AggregationTemporality .CUMULATIVE , 0 )
525545 )
526546
527547 # Ensure only one data point is collected
@@ -577,8 +597,8 @@ def test_consume_measurement_with_exemplars(self):
577597 )
578598
579599 # Collect the data points
580- data_points = view_instrument_match . collect (
581- AggregationTemporality .CUMULATIVE , 0
600+ data_points = list (
601+ view_instrument_match . collect ( AggregationTemporality .CUMULATIVE , 0 )
582602 )
583603
584604 # Ensure only one data point is collected
@@ -660,19 +680,9 @@ def test_consume_measurement_with_custom_reservoir_factory(self):
660680 )
661681 )
662682
663- # view_instrument_match.consume_measurement(
664- # Measurement(
665- # value=30.0, # Should go into the outliners bucket
666- # time_unix_nano=time_ns(),
667- # instrument=instrument1,
668- # context=Context(),
669- # attributes={"attribute3": "value3"},
670- # )
671- # )
672-
673683 # Collect the data points
674- data_points = view_instrument_match . collect (
675- AggregationTemporality .CUMULATIVE , 0
684+ data_points = list (
685+ view_instrument_match . collect ( AggregationTemporality .CUMULATIVE , 0 )
676686 )
677687
678688 # Ensure three data points are collected, one for each bucket
@@ -692,4 +702,3 @@ def test_consume_measurement_with_custom_reservoir_factory(self):
692702 self .assertEqual (
693703 data_points [2 ].exemplars [0 ].value , 15.0
694704 ) # Third bucket
695- # self.assertEqual(data_points[2].exemplars[0].value, 30.0) # Outliner bucket
0 commit comments