-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Implement otel retry metrics #12064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Implement otel retry metrics #12064
Conversation
opentelemetry/src/main/java/io/grpc/opentelemetry/internal/OpenTelemetryConstants.java
Outdated
Show resolved
Hide resolved
opentelemetry/src/main/java/io/grpc/opentelemetry/GrpcOpenTelemetry.java
Show resolved
Hide resolved
@@ -64,8 +65,8 @@ public Stopwatch get() { | |||
}; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the gRFC has had recent updates, waiting for it to get merged before doing further changes...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, there had been discussions yesterday about the recent changes to the retry metrics and whether they helped and such. The implementation should be mostly the same, but it isn't probably worth chasing the gRFC for the moment.
a7a16ce
to
3529769
Compare
3529769
to
bd69ed5
Compare
long hedgesPerCall = 0; | ||
long attempts = hedgedAttemptsPerCall.get(); | ||
if (attempts > 0) { | ||
hedgesPerCall = attempts - 1; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should hedges be subtracted by 1 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hedged attempts don't include the original attempt so we shouldn't subtract.
module.resource.clientCallDurationCounter() | ||
.record(callLatencyNanos * SECONDS_PER_NANO, attribute); | ||
module.resource.clientCallDurationCounter().record( | ||
callLatencyNanos * SECONDS_PER_NANO, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
callLatencyNanos is already in nanos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, nanos * seconds / nanos = seconds (duration unit is "s")
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is not addressed.
opentelemetry/src/main/java/io/grpc/opentelemetry/OpenTelemetryMetricsModule.java
Outdated
Show resolved
Hide resolved
opentelemetry/src/main/java/io/grpc/opentelemetry/OpenTelemetryMetricsModule.java
Show resolved
Hide resolved
Optional<MetricData> metric = openTelemetryTesting.getMetrics().stream() | ||
.filter(m -> m.getName().equals(metricName)) | ||
.findFirst(); | ||
if (metric.isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When will this metric not be present for the operations done by the tested on the tracer?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever they are not enabled or have default values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is test code, it is risky to have the assertion inside an if statement. If the absence of the metric is not expected, then it should not cause the test to pass.
module.resource.clientCallDurationCounter() | ||
.record(callLatencyNanos * SECONDS_PER_NANO, attribute); | ||
module.resource.clientCallDurationCounter().record( | ||
callLatencyNanos * SECONDS_PER_NANO, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yep, nanos * seconds / nanos = seconds (duration unit is "s")
Optional<MetricData> metric = openTelemetryTesting.getMetrics().stream() | ||
.filter(m -> m.getName().equals(metricName)) | ||
.findFirst(); | ||
if (metric.isPresent()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whenever they are not enabled or have default values
if (info.isTransparentRetry()) { | ||
transparentRetriesPerCall.incrementAndGet(); | ||
} else if (info.isHedging()) { | ||
hedgedAttemptsPerCall.incrementAndGet(); | ||
} else { | ||
attemptsPerCall.incrementAndGet(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this not assume them to be mutually exclusive ?
implements A96