Skip to content

Commit

Permalink
Rename ExplicitBucketBoundaries to explicit_bucket_boundaries
Browse files Browse the repository at this point in the history
  • Loading branch information
xrmx committed Dec 23, 2024
1 parent e5ca6a4 commit 181596b
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion opentelemetry-api/src/opentelemetry/util/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@


class MetricsInstrumentAdvisory(TypedDict):
ExplicitBucketBoundaries: Optional[AnyValue]
explicit_bucket_boundaries: Optional[AnyValue]
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def create_histogram(
if advisory is not None:
raise_error = False
try:
boundaries = advisory["ExplicitBucketBoundaries"]
boundaries = advisory["explicit_bucket_boundaries"]
raise_error = not (
boundaries
and all(isinstance(e, (int, float)) for e in boundaries)
Expand All @@ -217,7 +217,7 @@ def create_histogram(

if raise_error:
raise ValueError(
"Advisory must be a dict with ExplicitBucketBoundaries key containing a sequence of numbers"
"Advisory must be a dict with explicit_bucket_boundaries key containing a sequence of numbers"
)

(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1277,7 +1277,7 @@ def _create_aggregation(

if isinstance(instrument, Histogram):
boundaries: Optional[Sequence[float]] = (
instrument.advisory.get("ExplicitBucketBoundaries")
instrument.advisory.get("explicit_bucket_boundaries")
if instrument.advisory is not None
else None
)
Expand Down
2 changes: 1 addition & 1 deletion opentelemetry-sdk/tests/metrics/test_aggregation.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def test_histogram_with_advisory(self):
"name",
Mock(),
Mock(),
advisory={"ExplicitBucketBoundaries": boundaries},
advisory={"explicit_bucket_boundaries": boundaries},
),
Mock(),
_default_reservoir_factory,
Expand Down
10 changes: 5 additions & 5 deletions opentelemetry-sdk/tests/metrics/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,22 +505,22 @@ def test_create_histogram_with_advisory(self):
"name",
unit="unit",
description="description",
advisory={"ExplicitBucketBoundaries": [0, 1, 2]},
advisory={"explicit_bucket_boundaries": [0, 1, 2]},
)

self.assertIsInstance(histogram, Histogram)
self.assertEqual(histogram.name, "name")
self.assertEqual(
histogram.advisory, {"ExplicitBucketBoundaries": [0, 1, 2]}
histogram.advisory, {"explicit_bucket_boundaries": [0, 1, 2]}
)

def test_create_histogram_advisory_validation(self):
advisories = [
{"ExplicitBucketBoundaries": None},
{"ExplicitBucketBoundaries": []},
{"explicit_bucket_boundaries": None},
{"explicit_bucket_boundaries": []},
{},
[],
{"ExplicitBucketBoundaries": [1, 2.0, "3"]},
{"explicit_bucket_boundaries": [1, 2.0, "3"]},
]
for advisory in advisories:
with self.subTest(advisory=advisory):
Expand Down

0 comments on commit 181596b

Please sign in to comment.