File tree Expand file tree Collapse file tree 3 files changed +40
-5
lines changed
src/opentelemetry/sdk/metrics/_internal
tests/metrics/integration_test Expand file tree Collapse file tree 3 files changed +40
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
88## Unreleased
99
10+ - Fix ` start_time_unix_nano ` for delta collection for sum aggregation
11+ ([ #4009 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4009 ) )
1012- Do not execute Flask Tests in debug mode
1113 ([ #3956 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/3956 ) )
1214- When encountering an error encoding metric attributes in the OTLP exporter, log the key that had an error.
Original file line number Diff line number Diff line change @@ -278,16 +278,16 @@ def collect(
278278 is AggregationTemporality .DELTA
279279 ):
280280
281- if current_value is None :
282- return None
283-
284281 previous_collection_start_nano = (
285282 self ._previous_collection_start_nano
286283 )
287284 self ._previous_collection_start_nano = (
288285 collection_start_nano
289286 )
290287
288+ if current_value is None :
289+ return None
290+
291291 return NumberDataPoint (
292292 attributes = self ._attributes ,
293293 start_time_unix_nano = previous_collection_start_nano ,
Original file line number Diff line number Diff line change 1515from itertools import count
1616from logging import ERROR
1717from platform import system
18+ from time import sleep
1819from unittest import TestCase
1920
2021from pytest import mark
@@ -345,11 +346,43 @@ def test_synchronous_delta_temporality(self):
345346
346347 results .append (reader .get_metrics_data ())
347348
348- provider .shutdown ()
349-
350349 for metrics_data in results :
351350 self .assertIsNone (metrics_data )
352351
352+ results = []
353+
354+ counter .add (1 )
355+ results .append (reader .get_metrics_data ())
356+
357+ sleep (0.1 )
358+ results .append (reader .get_metrics_data ())
359+
360+ counter .add (2 )
361+ results .append (reader .get_metrics_data ())
362+
363+ metric_data_0 = (
364+ results [0 ]
365+ .resource_metrics [0 ]
366+ .scope_metrics [0 ]
367+ .metrics [0 ]
368+ .data .data_points [0 ]
369+ )
370+ metric_data_2 = (
371+ results [2 ]
372+ .resource_metrics [0 ]
373+ .scope_metrics [0 ]
374+ .metrics [0 ]
375+ .data .data_points [0 ]
376+ )
377+
378+ self .assertIsNone (results [1 ])
379+
380+ self .assertGreater (
381+ metric_data_2 .start_time_unix_nano , metric_data_0 .time_unix_nano
382+ )
383+
384+ provider .shutdown ()
385+
353386 @mark .skipif (
354387 system () != "Linux" ,
355388 reason = (
You can’t perform that action at this time.
0 commit comments