From 5f06815437fdc641135dbc40a71d488267c416d2 Mon Sep 17 00:00:00 2001 From: Nikolai Amelichev Date: Wed, 11 Dec 2024 13:50:07 +0100 Subject: [PATCH] #350: Improve logging practices in `BaseGrpcTransport` and `GrpcChannel` --- .../java/tech/ydb/core/impl/BaseGrpcTransport.java | 12 ++++++------ .../java/tech/ydb/core/impl/pool/GrpcChannel.java | 7 +++---- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/tech/ydb/core/impl/BaseGrpcTransport.java b/core/src/main/java/tech/ydb/core/impl/BaseGrpcTransport.java index efa9eea5..5e3f4cf9 100644 --- a/core/src/main/java/tech/ydb/core/impl/BaseGrpcTransport.java +++ b/core/src/main/java/tech/ydb/core/impl/BaseGrpcTransport.java @@ -92,10 +92,10 @@ public CompletableFuture> 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)); } } @@ -133,10 +133,10 @@ public GrpcReadStream 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)); } @@ -177,10 +177,10 @@ public GrpcReadWriteStream 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)); } diff --git a/core/src/main/java/tech/ydb/core/impl/pool/GrpcChannel.java b/core/src/main/java/tech/ydb/core/impl/pool/GrpcChannel.java index cfe6d161..47b9b3b8 100644 --- a/core/src/main/java/tech/ydb/core/impl/pool/GrpcChannel.java +++ b/core/src/main/java/tech/ydb/core/impl/pool/GrpcChannel.java @@ -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); } } @@ -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;