Skip to content

Commit d2e8c60

Browse files
committed
Review comments addressed
1 parent e0715f9 commit d2e8c60

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

instrumentation/failsafe-3.0/library/src/main/java/io/opentelemetry/instrumentation/failsafe/v3_0/FailsafeTelemetry.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
import io.opentelemetry.api.metrics.LongCounter;
2222
import io.opentelemetry.api.metrics.LongHistogram;
2323
import io.opentelemetry.api.metrics.Meter;
24-
import java.util.stream.Collectors;
25-
import java.util.stream.LongStream;
24+
import java.util.Arrays;
2625

2726
/** Entrypoint for instrumenting Failsafe components. */
2827
public final class FailsafeTelemetry {
@@ -102,10 +101,7 @@ public <R> RetryPolicy<R> createRetryPolicy(RetryPolicy<R> delegate, String retr
102101
.histogramBuilder("failsafe.retry_policy.attempts")
103102
.setDescription("Histogram of number of attempts for each execution.")
104103
.ofLongs()
105-
.setExplicitBucketBoundariesAdvice(
106-
LongStream.range(1, userConfig.getMaxAttempts() + 1)
107-
.boxed()
108-
.collect(Collectors.toList()))
104+
.setExplicitBucketBoundariesAdvice(Arrays.asList(1L, 2L, 3L, 5L))
109105
.build();
110106
Attributes attributes = Attributes.of(RETRY_POLICY_NAME, retryPolicyName);
111107
return RetryPolicy.builder(userConfig)

instrumentation/failsafe-3.0/library/src/test/java/io/opentelemetry/instrumentation/failsafe/v3_0/FailsafeTelemetryTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ void captureRetryPolicyMetrics() {
101101
failsafeTelemetry.createRetryPolicy(userRetryPolicy, "testing");
102102

103103
// when
104-
for (int i = 0; i <= 3; i++) {
104+
for (int i = 0; i <= 4; i++) {
105105
int temp = i;
106106
AtomicInteger retry = new AtomicInteger(0);
107107
Failsafe.with(instrumentedRetryPolicy)
@@ -131,7 +131,7 @@ void captureRetryPolicyMetrics() {
131131
.anyMatch(
132132
p ->
133133
p.getAttributes().equals(buildExpectedRetryPolicyAttributes("failure"))
134-
&& p.getValue() == 1);
134+
&& p.getValue() == 2);
135135
assertThat(executionCountMetric.getPoints())
136136
.anyMatch(
137137
p ->
@@ -153,15 +153,15 @@ void captureRetryPolicyMetrics() {
153153
&& p.getMin() == 1
154154
&& p.getMax() == 3
155155
&& p.getAttributes().equals(buildExpectedRetryPolicyAttributes("success"))
156-
&& Arrays.equals(p.getCounts().toArray(), new Long[] {1L, 1L, 1L, 0L}));
156+
&& Arrays.equals(p.getCounts().toArray(), new Long[] {1L, 1L, 1L, 0L, 0L}));
157157
assertThat(pointData)
158158
.anyMatch(
159159
p ->
160-
p.getCount() == 1
160+
p.getCount() == 2
161161
&& p.getMin() == 3
162162
&& p.getMax() == 3
163163
&& p.getAttributes().equals(buildExpectedRetryPolicyAttributes("failure"))
164-
&& Arrays.equals(p.getCounts().toArray(), new Long[] {0L, 0L, 1L, 0L}));
164+
&& Arrays.equals(p.getCounts().toArray(), new Long[] {0L, 0L, 2L, 0L, 0L}));
165165
}
166166

167167
private static Consumer<LongPointAssert> buildCircuitBreakerAssertion(

0 commit comments

Comments
 (0)