Skip to content

Commit b753d38

Browse files
authored
Merge pull request #351 from nvamelichev/improve-logging-BaseGrpcTransport-GrpcChannel
#350: Improve logging practices in `BaseGrpcTransport` and `GrpcChannel`
2 parents 2984ceb + 5f06815 commit b753d38

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

core/src/main/java/tech/ydb/core/impl/BaseGrpcTransport.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -92,10 +92,10 @@ public <ReqT, RespT> CompletableFuture<Result<RespT>> unaryCall(
9292

9393
return new UnaryCall<>(traceId, call, handler).startCall(request, makeMetadataFromSettings(settings));
9494
} catch (UnexpectedResultException ex) {
95-
logger.error("UnaryCall[{}] got unexprected status {}", traceId, ex.getStatus());
95+
logger.warn("UnaryCall[{}] got unexprected status {}", traceId, ex.getStatus());
9696
return CompletableFuture.completedFuture(Result.fail(ex));
9797
} catch (RuntimeException ex) {
98-
logger.error("UnaryCall[{}] got problem {}", traceId, ex.getMessage());
98+
logger.warn("UnaryCall[{}] got problem {}", traceId, ex.getMessage());
9999
return CompletableFuture.completedFuture(Result.error(ex.getMessage(), ex));
100100
}
101101
}
@@ -133,10 +133,10 @@ public <ReqT, RespT> GrpcReadStream<RespT> readStreamCall(
133133

134134
return new ReadStreamCall<>(traceId, call, request, makeMetadataFromSettings(settings), handler);
135135
} catch (UnexpectedResultException ex) {
136-
logger.error("ReadStreamCall[{}] got unexpected status {}", traceId, ex.getStatus());
136+
logger.warn("ReadStreamCall[{}] got unexpected status {}", traceId, ex.getStatus());
137137
return new EmptyStream<>(ex.getStatus());
138138
} catch (RuntimeException ex) {
139-
logger.error("ReadStreamCall[{}] got problem {}", traceId, ex.getMessage());
139+
logger.warn("ReadStreamCall[{}] got problem {}", traceId, ex.getMessage());
140140
Issue issue = Issue.of(ex.getMessage(), Issue.Severity.ERROR);
141141
return new EmptyStream<>(Status.of(StatusCode.CLIENT_INTERNAL_ERROR, issue));
142142
}
@@ -177,10 +177,10 @@ public <ReqT, RespT> GrpcReadWriteStream<RespT, ReqT> readWriteStreamCall(
177177
traceId, call, makeMetadataFromSettings(settings), getAuthCallOptions(), handler
178178
);
179179
} catch (UnexpectedResultException ex) {
180-
logger.error("ReadWriteStreamCall[{}] got unexpected status {}", traceId, ex.getStatus());
180+
logger.warn("ReadWriteStreamCall[{}] got unexpected status {}", traceId, ex.getStatus());
181181
return new EmptyStream<>(ex.getStatus());
182182
} catch (RuntimeException ex) {
183-
logger.error("ReadWriteStreamCall[{}] got problem {}", traceId, ex.getMessage());
183+
logger.warn("ReadWriteStreamCall[{}] got problem {}", traceId, ex.getMessage());
184184
Issue issue = Issue.of(ex.getMessage(), Issue.Severity.ERROR);
185185
return new EmptyStream<>(Status.of(StatusCode.CLIENT_INTERNAL_ERROR, issue));
186186
}

core/src/main/java/tech/ydb/core/impl/pool/GrpcChannel.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public GrpcChannel(EndpointRecord endpoint, ManagedChannelFactory factory) {
3434
this.readyWatcher = new ReadyWatcher();
3535
this.readyWatcher.checkState();
3636
} catch (Throwable th) {
37-
logger.error("cannot create channel", th);
3837
throw new RuntimeException("cannot create channel", th);
3938
}
4039
}
@@ -80,13 +79,13 @@ public Channel getReadyChannel() {
8079
try {
8180
return future.get(connectTimeoutMs, TimeUnit.MILLISECONDS);
8281
} catch (InterruptedException ex) {
83-
logger.error("Grpc channel {} ready waiting is interrupted: ", endpoint, ex);
82+
logger.warn("Grpc channel {} ready waiting is interrupted: ", endpoint, ex);
8483
Thread.currentThread().interrupt();
8584
} catch (ExecutionException ex) {
86-
logger.error("Grpc channel {} connecting problem: ", endpoint, ex);
85+
logger.warn("Grpc channel {} connecting problem: ", endpoint, ex);
8786
throw new RuntimeException("Channel " + endpoint + " connecting problem", ex);
8887
} catch (TimeoutException ex) {
89-
logger.error("Grpc channel {} connect timeout exceeded", endpoint);
88+
logger.warn("Grpc channel {} connect timeout exceeded", endpoint);
9089
throw new RuntimeException("Channel " + endpoint + " connecting timeout");
9190
}
9291
return null;

0 commit comments

Comments
 (0)