From 024e07d3fd9cf46e83411936facd8c9733d9884e Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Tue, 20 Aug 2024 17:14:31 -0600 Subject: [PATCH 1/3] This test case fails with the change in this commit --- .../test_exponential_bucket_histogram_aggregation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py index 85c28070c15..5445e472761 100644 --- a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py +++ b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py @@ -1043,7 +1043,7 @@ def collect_and_validate(values, histogram) -> None: # run this test case with the same values used in a previous execution, # check the value printed by that previous execution of this test case # and use the same value for the seed variable in the line below. - # seed = 4539544373807492135 + seed = 3373389994391084876 random_generator = Random(seed) print(f"seed for {currentframe().f_code.co_name} is {seed}") From 626a0a3acb01320d4600edebcb448efd5199cec3 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Tue, 20 Aug 2024 17:36:56 -0600 Subject: [PATCH 2/3] This fixes the issue for that particular seed Fixes #4138 --- .../test_exponential_bucket_histogram_aggregation.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py index 5445e472761..2d5ff89b612 100644 --- a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py +++ b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py @@ -1043,7 +1043,7 @@ def collect_and_validate(values, histogram) -> None: # run this test case with the same values used in a previous execution, # check the value printed by that previous execution of this test case # and use the same value for the seed variable in the line below. - seed = 3373389994391084876 + # seed = 3373389994391084876 random_generator = Random(seed) print(f"seed for {currentframe().f_code.co_name} is {seed}") @@ -1051,6 +1051,8 @@ def collect_and_validate(values, histogram) -> None: values = [] for i in range(2000): value = random_generator.randint(0, 1000) + while i == 0 and value == 0: + value = random_generator.randint(0, 1000) values.append(value) histogram.aggregate(Measurement(value, Mock())) if i % 20 == 0: From 74b427d8da5835f8b28e4ba146222fd19fad3ac4 Mon Sep 17 00:00:00 2001 From: Diego Hurtado Date: Wed, 21 Aug 2024 06:45:12 -0600 Subject: [PATCH 3/3] Update opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py Co-authored-by: Riccardo Magliocchetti --- .../test_exponential_bucket_histogram_aggregation.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py index 2d5ff89b612..7d025e33305 100644 --- a/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py +++ b/opentelemetry-sdk/tests/metrics/exponential_histogram/test_exponential_bucket_histogram_aggregation.py @@ -1050,9 +1050,8 @@ def collect_and_validate(values, histogram) -> None: values = [] for i in range(2000): - value = random_generator.randint(0, 1000) - while i == 0 and value == 0: - value = random_generator.randint(0, 1000) + # avoid both values being 0 + value = random_generator.randint(0 if i else 1, 1000) values.append(value) histogram.aggregate(Measurement(value, Mock())) if i % 20 == 0: