Skip to content

Commit

Permalink
[thin-client] Added debug logging for thin client single-get
Browse files Browse the repository at this point in the history
Logs are added before a single-get request is sent, and every potential
routes of response on the client side.
  • Loading branch information
huangminchn committed Feb 12, 2025
1 parent 2d31312 commit 5c6141d
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,18 +366,24 @@ public CompletableFuture<V> get(K key, Optional<ClientStats> stats, long preRequ
() -> transportClient.get(requestPath, RequestHeadersProvider.getThinClientGetHeaderMap()),
(response, throwable, responseCompleteReporter) -> {
try {
LOGGER.debug("Received response for store {}", getStoreName());
if (throwable != null) {
LOGGER.error("Error response for store {}", getStoreName(), throwable);
valueFuture.completeExceptionally(throwable);
} else if (response == null) {
LOGGER.debug("null response for store {}", getStoreName());
// Doesn't exist
valueFuture.complete(null);
} else if (!response.isSchemaIdValid()) {
LOGGER.error("Invalid schema id for store {}", getStoreName());
valueFuture.completeExceptionally(
new VeniceClientException("No valid schema id received for single-get request!"));
} else {
LOGGER.debug("Valid response for store {}", getStoreName());
CompressionStrategy compressionStrategy = response.getCompressionStrategy();
long decompressionStartTime = System.nanoTime();
ByteBuffer data = decompressRecord(compressionStrategy, ByteBuffer.wrap(response.getBody()));
LOGGER.debug("Decompressed response for store {}", getStoreName());
stats.ifPresent(
(clientStats) -> clientStats
.recordResponseDecompressionTime(LatencyUtils.getElapsedTimeFromNSToMS(decompressionStartTime)));
Expand All @@ -386,6 +392,7 @@ public CompletableFuture<V> get(K key, Optional<ClientStats> stats, long preRequ
responseCompleteReporter.report();
}
} catch (Exception e) {
LOGGER.error("Caught exception while handling response", e);
// Defensive code
if (!valueFuture.isDone()) {
valueFuture.completeExceptionally(e);
Expand Down Expand Up @@ -519,6 +526,7 @@ private <R> CompletableFuture<R> requestSubmissionWithStatsHandling(
Supplier<CompletableFuture<TransportClientResponse>> requestSubmitter,
ResponseHandler<R> responseHandler) throws VeniceClientException {
final long preSubmitTimeInNS = System.nanoTime();
LOGGER.debug("Sending request for store {}", getStoreName());
CompletableFuture<TransportClientResponse> transportFuture = requestSubmitter.get();

BiFunction<TransportClientResponse, Throwable, R> responseHandlerWithStats = (clientResponse, throwable) -> {
Expand Down

0 comments on commit 5c6141d

Please sign in to comment.