File tree 3 files changed +41
-6
lines changed
src/opentelemetry/sdk/metrics/_internal
tests/metrics/integration_test
3 files changed +41
-6
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ 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
10
+ - Fix ` start_time_unix_nano ` for delta collection for explicit bucket histogram aggregation
11
11
([ #4009 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4009 ) )
12
+ - Fix ` start_time_unix_nano ` for delta collection for sum aggregation
13
+ ([ #4011 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/4011 ) )
12
14
- Do not execute Flask Tests in debug mode
13
15
([ #3956 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/3956 ) )
14
16
- 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 @@ -471,16 +471,16 @@ def collect(
471
471
is AggregationTemporality .DELTA
472
472
):
473
473
474
- if current_value is None :
475
- return None
476
-
477
474
previous_collection_start_nano = (
478
475
self ._previous_collection_start_nano
479
476
)
480
477
self ._previous_collection_start_nano = (
481
478
collection_start_nano
482
479
)
483
480
481
+ if current_value is None :
482
+ return None
483
+
484
484
return HistogramDataPoint (
485
485
attributes = self ._attributes ,
486
486
start_time_unix_nano = previous_collection_start_nano ,
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
from platform import system
16
+ from time import sleep
16
17
from unittest import TestCase
17
18
18
19
from pytest import mark
@@ -123,11 +124,43 @@ def test_synchronous_delta_temporality(self):
123
124
124
125
results .append (reader .get_metrics_data ())
125
126
126
- provider .shutdown ()
127
-
128
127
for metrics_data in results :
129
128
self .assertIsNone (metrics_data )
130
129
130
+ results = []
131
+
132
+ histogram .record (1 )
133
+ results .append (reader .get_metrics_data ())
134
+
135
+ sleep (0.1 )
136
+ results .append (reader .get_metrics_data ())
137
+
138
+ histogram .record (2 )
139
+ results .append (reader .get_metrics_data ())
140
+
141
+ metric_data_0 = (
142
+ results [0 ]
143
+ .resource_metrics [0 ]
144
+ .scope_metrics [0 ]
145
+ .metrics [0 ]
146
+ .data .data_points [0 ]
147
+ )
148
+ metric_data_2 = (
149
+ results [2 ]
150
+ .resource_metrics [0 ]
151
+ .scope_metrics [0 ]
152
+ .metrics [0 ]
153
+ .data .data_points [0 ]
154
+ )
155
+
156
+ self .assertIsNone (results [1 ])
157
+
158
+ self .assertGreater (
159
+ metric_data_2 .start_time_unix_nano , metric_data_0 .time_unix_nano
160
+ )
161
+
162
+ provider .shutdown ()
163
+
131
164
@mark .skipif (
132
165
system () != "Linux" ,
133
166
reason = (
You can’t perform that action at this time.
0 commit comments