Skip to content

Commit

Permalink
Merge pull request #351 from nvamelichev/improve-logging-BaseGrpcTran…
Browse files Browse the repository at this point in the history
…sport-GrpcChannel

#350: Improve logging practices in `BaseGrpcTransport` and `GrpcChannel`
  • Loading branch information
alex268 authored Dec 11, 2024
2 parents 2984ceb + 5f06815 commit b753d38
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
12 changes: 6 additions & 6 deletions core/src/main/java/tech/ydb/core/impl/BaseGrpcTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ public <ReqT, RespT> CompletableFuture<Result<RespT>> unaryCall(

return new UnaryCall<>(traceId, call, handler).startCall(request, makeMetadataFromSettings(settings));
} catch (UnexpectedResultException ex) {
logger.error("UnaryCall[{}] got unexprected status {}", traceId, ex.getStatus());
logger.warn("UnaryCall[{}] got unexprected status {}", traceId, ex.getStatus());
return CompletableFuture.completedFuture(Result.fail(ex));
} catch (RuntimeException ex) {
logger.error("UnaryCall[{}] got problem {}", traceId, ex.getMessage());
logger.warn("UnaryCall[{}] got problem {}", traceId, ex.getMessage());
return CompletableFuture.completedFuture(Result.error(ex.getMessage(), ex));
}
}
Expand Down Expand Up @@ -133,10 +133,10 @@ public <ReqT, RespT> GrpcReadStream<RespT> readStreamCall(

return new ReadStreamCall<>(traceId, call, request, makeMetadataFromSettings(settings), handler);
} catch (UnexpectedResultException ex) {
logger.error("ReadStreamCall[{}] got unexpected status {}", traceId, ex.getStatus());
logger.warn("ReadStreamCall[{}] got unexpected status {}", traceId, ex.getStatus());
return new EmptyStream<>(ex.getStatus());
} catch (RuntimeException ex) {
logger.error("ReadStreamCall[{}] got problem {}", traceId, ex.getMessage());
logger.warn("ReadStreamCall[{}] got problem {}", traceId, ex.getMessage());
Issue issue = Issue.of(ex.getMessage(), Issue.Severity.ERROR);
return new EmptyStream<>(Status.of(StatusCode.CLIENT_INTERNAL_ERROR, issue));
}
Expand Down Expand Up @@ -177,10 +177,10 @@ public <ReqT, RespT> GrpcReadWriteStream<RespT, ReqT> readWriteStreamCall(
traceId, call, makeMetadataFromSettings(settings), getAuthCallOptions(), handler
);
} catch (UnexpectedResultException ex) {
logger.error("ReadWriteStreamCall[{}] got unexpected status {}", traceId, ex.getStatus());
logger.warn("ReadWriteStreamCall[{}] got unexpected status {}", traceId, ex.getStatus());
return new EmptyStream<>(ex.getStatus());
} catch (RuntimeException ex) {
logger.error("ReadWriteStreamCall[{}] got problem {}", traceId, ex.getMessage());
logger.warn("ReadWriteStreamCall[{}] got problem {}", traceId, ex.getMessage());
Issue issue = Issue.of(ex.getMessage(), Issue.Severity.ERROR);
return new EmptyStream<>(Status.of(StatusCode.CLIENT_INTERNAL_ERROR, issue));
}
Expand Down
7 changes: 3 additions & 4 deletions core/src/main/java/tech/ydb/core/impl/pool/GrpcChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public GrpcChannel(EndpointRecord endpoint, ManagedChannelFactory factory) {
this.readyWatcher = new ReadyWatcher();
this.readyWatcher.checkState();
} catch (Throwable th) {
logger.error("cannot create channel", th);
throw new RuntimeException("cannot create channel", th);
}
}
Expand Down Expand Up @@ -80,13 +79,13 @@ public Channel getReadyChannel() {
try {
return future.get(connectTimeoutMs, TimeUnit.MILLISECONDS);
} catch (InterruptedException ex) {
logger.error("Grpc channel {} ready waiting is interrupted: ", endpoint, ex);
logger.warn("Grpc channel {} ready waiting is interrupted: ", endpoint, ex);
Thread.currentThread().interrupt();
} catch (ExecutionException ex) {
logger.error("Grpc channel {} connecting problem: ", endpoint, ex);
logger.warn("Grpc channel {} connecting problem: ", endpoint, ex);
throw new RuntimeException("Channel " + endpoint + " connecting problem", ex);
} catch (TimeoutException ex) {
logger.error("Grpc channel {} connect timeout exceeded", endpoint);
logger.warn("Grpc channel {} connect timeout exceeded", endpoint);
throw new RuntimeException("Channel " + endpoint + " connecting timeout");
}
return null;
Expand Down

0 comments on commit b753d38

Please sign in to comment.