Skip to content

Commit 43a746b

Browse files
committed
suggested changes
1 parent fab9a26 commit 43a746b

3 files changed

Lines changed: 8 additions & 20 deletions

File tree

opentelemetry/src/main/java/io/grpc/opentelemetry/OpenTelemetryMetricsModule.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -436,29 +436,17 @@ void recordFinishedCall() {
436436

437437
// Retry counts
438438
if (module.resource.clientCallRetriesCounter() != null) {
439-
440-
long retriesPerCall = 0;
441-
long attempts = attemptsPerCall.get();
442-
if (attempts > 0) {
443-
retriesPerCall = attempts - 1;
444-
}
445-
439+
long retriesPerCall = attemptsPerCall.get() - 1 >= 0 ? attemptsPerCall.get() - 1 : 0;
446440
if (retriesPerCall > 0) {
447441
module.resource.clientCallRetriesCounter().record(retriesPerCall, baseAttributes);
448442
}
449443
}
450444

451445
// Hedge counts
452446
if (module.resource.clientCallHedgesCounter() != null) {
453-
454-
long hedgesPerCall = 0;
455-
long attempts = hedgedAttemptsPerCall.get();
456-
if (attempts > 0) {
457-
hedgesPerCall = attempts - 1;
458-
}
459-
460-
if (hedgesPerCall > 0) {
461-
module.resource.clientCallHedgesCounter().record(hedgesPerCall, baseAttributes);
447+
if (hedgedAttemptsPerCall.get() > 0) {
448+
module.resource.clientCallHedgesCounter()
449+
.record(hedgedAttemptsPerCall.get(), baseAttributes);
462450
}
463451
}
464452

opentelemetry/src/main/java/io/grpc/opentelemetry/internal/OpenTelemetryConstants.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ public final class OpenTelemetryConstants {
4949
0L, 1024L, 2048L, 4096L, 16384L, 65536L, 262144L, 1048576L, 4194304L, 16777216L,
5050
67108864L, 268435456L, 1073741824L, 4294967296L);
5151

52-
public static final List<Long> RETRY_BUCKETS = ImmutableList.of(0L, 1L, 2L, 3L, 4L, 5L);
52+
public static final List<Long> RETRY_BUCKETS = ImmutableList.of(1L, 2L, 3L, 4L, 5L);
5353

5454
public static final List<Long> TRANSPARENT_RETRY_BUCKETS =
55-
ImmutableList.of(0L, 1L, 2L, 3L, 4L, 5L, 10L);
55+
ImmutableList.of(1L, 2L, 3L, 4L, 5L, 10L);
5656

57-
public static final List<Long> HEDGE_BUCKETS = ImmutableList.of(0L, 1L, 2L, 3L, 4L, 5L);
57+
public static final List<Long> HEDGE_BUCKETS = ImmutableList.of(1L, 2L, 3L, 4L, 5L);
5858

5959
private OpenTelemetryConstants() {
6060
}

opentelemetry/src/test/java/io/grpc/opentelemetry/OpenTelemetryMetricsModuleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1081,7 +1081,7 @@ public void recordAttemptMetrics_withHedgedCalls() {
10811081
.hasHistogramSatisfying(histogram -> histogram.hasPointsSatisfying(
10821082
point -> point
10831083
.hasCount(1)
1084-
.hasSum(1)
1084+
.hasSum(2)
10851085
.hasAttributes(finalAttributes))),
10861086
metric -> assertThat(metric)
10871087
.hasName(CLIENT_CALL_RETRY_DELAY)

0 commit comments

Comments
 (0)