Skip to content

Commit

Permalink
Fix another issue and add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl committed Jul 11, 2024
1 parent f2ba07f commit 4d50470
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -764,16 +764,16 @@ def collect(
is AggregationTemporality.DELTA
):

if value_positive is None and value_negative is None:
return None

previous_collection_start_nano = (
self._previous_collection_start_nano
)
self._previous_collection_start_nano = (
collection_start_nano
)

if value_positive is None and value_negative is None:
return None

return ExponentialHistogramDataPoint(
attributes=self._attributes,
start_time_unix_nano=previous_collection_start_nano,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
# limitations under the License.

from platform import system
from time import sleep
from unittest import TestCase

from pytest import mark
Expand Down Expand Up @@ -125,6 +126,40 @@ def test_synchronous_delta_temporality(self):
for metrics_data in results:
self.assertIsNone(metrics_data)

results = []

histogram.record(1)
results.append(reader.get_metrics_data())

sleep(0.1)
results.append(reader.get_metrics_data())

histogram.record(2)
results.append(reader.get_metrics_data())

metric_data_0 = (
results[0]
.resource_metrics[0]
.scope_metrics[0]
.metrics[0]
.data.data_points[0]
)
metric_data_2 = (
results[2]
.resource_metrics[0]
.scope_metrics[0]
.metrics[0]
.data.data_points[0]
)

self.assertIsNone(results[1])

self.assertGreater(
metric_data_2.start_time_unix_nano, metric_data_0.time_unix_nano
)

provider.shutdown()

@mark.skipif(
system() == "Windows",
reason=(
Expand Down

0 comments on commit 4d50470

Please sign in to comment.