From be325b28694beb664020be39e1876ffb54d7efd9 Mon Sep 17 00:00:00 2001 From: Bogdan Drutu Date: Tue, 13 Jun 2023 09:31:56 -0700 Subject: [PATCH] Make Advice proper immutable class Signed-off-by: Bogdan Drutu --- .../sdk/metrics/internal/descriptor/Advice.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/descriptor/Advice.java b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/descriptor/Advice.java index d88ab7359e6..a770efb5743 100644 --- a/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/descriptor/Advice.java +++ b/sdk/metrics/src/main/java/io/opentelemetry/sdk/metrics/internal/descriptor/Advice.java @@ -6,6 +6,8 @@ package io.opentelemetry.sdk.metrics.internal.descriptor; import com.google.auto.value.AutoValue; +import java.util.ArrayList; +import java.util.Collections; import java.util.List; import javax.annotation.Nullable; import javax.annotation.concurrent.Immutable; @@ -20,7 +22,17 @@ public static Advice empty() { return EMPTY_ADVICE; } + /** + * Creates a new {@link Advice} with the given explicit bucket histogram boundaries. + * + * @param explicitBucketBoundaries the explicit bucket histogram boundaries. + * @return a new {@link Advice} with the given bucket boundaries. + */ public static Advice create(@Nullable List explicitBucketBoundaries) { + if (explicitBucketBoundaries != null) { + explicitBucketBoundaries = + Collections.unmodifiableList(new ArrayList<>(explicitBucketBoundaries)); + } return new AutoValue_Advice(explicitBucketBoundaries); }