File tree Expand file tree Collapse file tree 2 files changed +38
-3
lines changed
src/opentelemetry/sdk/metrics/_internal
tests/metrics/integration_test Expand file tree Collapse file tree 2 files changed +38
-3
lines changed Original file line number Diff line number Diff line change @@ -764,16 +764,16 @@ def collect(
764764 is AggregationTemporality .DELTA
765765 ):
766766
767- if value_positive is None and value_negative is None :
768- return None
769-
770767 previous_collection_start_nano = (
771768 self ._previous_collection_start_nano
772769 )
773770 self ._previous_collection_start_nano = (
774771 collection_start_nano
775772 )
776773
774+ if value_positive is None and value_negative is None :
775+ return None
776+
777777 return ExponentialHistogramDataPoint (
778778 attributes = self ._attributes ,
779779 start_time_unix_nano = previous_collection_start_nano ,
Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515from platform import system
16+ from time import sleep
1617from unittest import TestCase
1718
1819from pytest import mark
@@ -125,6 +126,40 @@ def test_synchronous_delta_temporality(self):
125126 for metrics_data in results :
126127 self .assertIsNone (metrics_data )
127128
129+ results = []
130+
131+ histogram .record (1 )
132+ results .append (reader .get_metrics_data ())
133+
134+ sleep (0.1 )
135+ results .append (reader .get_metrics_data ())
136+
137+ histogram .record (2 )
138+ results .append (reader .get_metrics_data ())
139+
140+ metric_data_0 = (
141+ results [0 ]
142+ .resource_metrics [0 ]
143+ .scope_metrics [0 ]
144+ .metrics [0 ]
145+ .data .data_points [0 ]
146+ )
147+ metric_data_2 = (
148+ results [2 ]
149+ .resource_metrics [0 ]
150+ .scope_metrics [0 ]
151+ .metrics [0 ]
152+ .data .data_points [0 ]
153+ )
154+
155+ self .assertIsNone (results [1 ])
156+
157+ self .assertGreater (
158+ metric_data_2 .start_time_unix_nano , metric_data_0 .time_unix_nano
159+ )
160+
161+ provider .shutdown ()
162+
128163 @mark .skipif (
129164 system () == "Windows" ,
130165 reason = (
You can’t perform that action at this time.
0 commit comments