File tree 3 files changed +40
-5
lines changed
src/opentelemetry/sdk/metrics/_internal
tests/metrics/integration_test
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
7
7
8
8
## Unreleased
9
9
10
+ - Fix ` start_time_unix_nano ` for delta collection for sum aggregation
11
+ ([ #4009 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4009 ) )
10
12
- Do not execute Flask Tests in debug mode
11
13
([ #3956 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/3956 ) )
12
14
- 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(
278
278
is AggregationTemporality .DELTA
279
279
):
280
280
281
- if current_value is None :
282
- return None
283
-
284
281
previous_collection_start_nano = (
285
282
self ._previous_collection_start_nano
286
283
)
287
284
self ._previous_collection_start_nano = (
288
285
collection_start_nano
289
286
)
290
287
288
+ if current_value is None :
289
+ return None
290
+
291
291
return NumberDataPoint (
292
292
attributes = self ._attributes ,
293
293
start_time_unix_nano = previous_collection_start_nano ,
Original file line number Diff line number Diff line change 15
15
from itertools import count
16
16
from logging import ERROR
17
17
from platform import system
18
+ from time import sleep
18
19
from unittest import TestCase
19
20
20
21
from pytest import mark
@@ -345,11 +346,43 @@ def test_synchronous_delta_temporality(self):
345
346
346
347
results .append (reader .get_metrics_data ())
347
348
348
- provider .shutdown ()
349
-
350
349
for metrics_data in results :
351
350
self .assertIsNone (metrics_data )
352
351
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
+
353
386
@mark .skipif (
354
387
system () != "Linux" ,
355
388
reason = (
You can’t perform that action at this time.
0 commit comments