void-ptr974 commented on code in PR #26163:
URL: https://github.com/apache/pulsar/pull/26163#discussion_r3563009641
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/TopicLoadingContext.java:
##########
@@ -21,19 +21,15 @@
import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.TimeUnit;
import lombok.Getter;
-import lombok.RequiredArgsConstructor;
import lombok.Setter;
import org.apache.pulsar.common.naming.TopicName;
+import org.apache.pulsar.common.util.LatencyTracer;
import org.jspecify.annotations.Nullable;
-@RequiredArgsConstructor
-public class TopicLoadingContext {
+public class TopicLoadingContext extends LatencyTracer {
- private static final String EXAMPLE_LATENCY_OUTPUTS = "1234 ms (queued:
567)";
-
- private final long startNs = System.nanoTime();
+ private final LatencyTracer latencyTracer = new LatencyTracer(5);
Review Comment:
This field is unused now that TopicLoadingContext extends LatencyTracer; all
trace/latency calls use the inherited methods. Can we remove this extra
LatencyTracer allocation, or switch the class back to composition if that was
the intended design?
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/service/BrokerService.java:
##########
@@ -1313,31 +1313,31 @@ public CompletableFuture<Optional<Topic>>
getTopic(final TopicName topicName, bo
context.setProperties(properties);
}
topicFuture.exceptionally(t -> {
- final var now = System.nanoTime();
if (FutureUtil.unwrapCompletionException(t) instanceof
TimeoutException) {
log.warn()
.attr("topic", topicName)
- .attr("latencyMs", context.latencyMs(now))
+ .attr("latencyMs", context.latencyInMillis())
Review Comment:
This changes the failure/timeout latency from "elapsed until now" to
"elapsed until the last recorded checkpoint". If the topic load stalls in the
current async stage, that stage never records a checkpoint, so a timeout can
log a much smaller value, or even 0, instead of the actual timeout duration.
Could we keep measuring failure latency against System.nanoTime() here, or add
a final failure/timeout checkpoint before logging?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]