Skip to content

Commit

Permalink
Make Advice proper immutable class (#5532)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu committed Jun 14, 2023
1 parent 89a2ece commit cf3b0ef
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Double> explicitBucketBoundaries) {
if (explicitBucketBoundaries != null) {
explicitBucketBoundaries =
Collections.unmodifiableList(new ArrayList<>(explicitBucketBoundaries));
}
return new AutoValue_Advice(explicitBucketBoundaries);
}

Expand Down

0 comments on commit cf3b0ef

Please sign in to comment.