-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
INTERNAL: Add operation status message to log when operation is not successful. #80
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 완료입니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 완료
OperationStatus status = future.getStatus(); | ||
if (!status.isSuccess()) { | ||
logger.warn("failed to getValue a key: {}, status: {}, statusCode: {}", | ||
arcusKey, status.getMessage(), status.getStatusCode()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
단순히 key miss인 경우는 제외해야 할 것 같습니다.
그 외에는 어떤 OperationStatus가 있나요?
다른 연산들도 그 semantic에 따라
필요한 경우만 logging하여야 할 것 같습니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get은 항상 END로 끝나므로 key miss인 경우에 단순히 값만 없고 OperationStatus는 success 입니다.
OperationStatus의 StatusCode에 따라 로그 레벨을 다르게 출력하도록 수정했습니다. |
@uhm0311 발생 가능한 상태 코드를 살펴보고 특정 조건일 때에만 로깅을 남기는 것이 어떤가요? 다양한 케이스를 고려하다보니 현재 코드는 간단한 로깅 작업임에도 불구하고 한눈에 보고 이해하기 어렵습니다. 다만 하위 호환성으로 받아들이는 상태 코드가 버전마다 다르다면 어쩔 수 없이 이 형태로 구현해야 할 것 같긴 합니다. |
서버 응답 모음CLIENT_ERROR, SERVER_ERROR와 같은 에러는 없는 경우의 응답입니다. get키 존재 여부에 관계 없이 END, 성공 addSTORED, 값 저장 완료, 성공 deleteDELETED, 값 제거 완료, 성공 flushOK, Prefix가 존재하는 경우, 성공 무조건 로깅하는 이유evict 실패 원인에 대한 문의가 있었기 때문에 로그를 통해 NOT_FOUND이면 캐시 키가 없다는 것을 알리기 위함입니다. |
@oliviarla @brido4125 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 코드에서 임의로 timeout 발생 시킨 뒤 적절한 로그가 발생하는지
junit4에서 검증 가능하다면 하는게 좋을 것 같습니다.
Mockito와 같은 라이브러리들의 버전 문제인지는 모르겠지만 TestLogger 클래스 없이는 로그 메세지를 검증할 좋은 방법이 없어서 로그 메세지를 출력하지 않고 메모리에 저장해두는 TestLogger 클래스를 추가했습니다. |
저는 단순한 로깅 기능에 테스트코드까지 추가하는게 의미가 있는지 잘 모르겠는데, @uhm0311 님은 테스트코드가 필요하다고 보시나요? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
리뷰 완료
if (!status.isSuccess()) { | ||
logOperationStatus("getValue", "key", arcusKey, status, false); | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
아래 형태의 코드가 읽기 좋습니다.
value = future.get(timeoutMilliSeconds, TimeUnit.MILLISECONDS);
if (value != null) {
logger.debug("arcus cache hit for {}", arcusKey);
if (arcusFrontCache != null) {
arcusFrontCache.set(arcusKey, value, frontExpireSeconds);
}
} else {
logger.debug("arcus cache miss for {}", arcusKey);
if (!future.getStatus().isSuccess()) { // which error ??
OperationStatus status = future.getStatus();
logger.info("failed to get a key: {}, status: {}", arcusKey, status.getMessage());
}
}
위의 else에서 future.getStatus().isSuccess() == false 경우는 어떤 경우가 있나요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exceptional한 상황이 아니면 없습니다.
따라서 CLIENT_ERROR, SERVER_ERROR, CANCELLED를 포함하는 모든 실패 상황을 로깅합니다.
OperationStatus status = future.getStatus(); | ||
boolean debugLevel = status.getStatusCode() == StatusCode.ERR_NOT_FOUND; | ||
|
||
logOperationStatus("evict", "key", arcusKey, status, debugLevel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존에 아래와 같이 로깅하고 있었네요.
이 경우에는 status 정보만 추가하면 될 것 같습니다.
logger.info("failed to evict a key: {}", arcusKey);
OperationStatus status = future.getStatus(); | ||
boolean debugLevel = status.getStatusCode() == StatusCode.ERR_NOT_FOUND; | ||
|
||
logOperationStatus("clear", "prefix", arcusPrefix, status, debugLevel); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
여기도 기존 info 로그에 status.getMessage() 정보만 추가하면 될 것 같습니다.
if (!success) { | ||
logger.info("failed to put a key: {}", arcusKey); | ||
OperationStatus status = future.getStatus(); | ||
logOperationStatus("put", "key", arcusKey, status, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
기존 info 로그 메세지에 status 정보만 추가합시다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
status Code와 status Message 중에서 하나만 출력하면 될 것 같고,
어떤 내용이 나은 지는 확인해 주세요.
|
||
if (added && arcusFrontCache != null) { | ||
logOperationStatus("putIfAbsent", "key", arcusKey, status, debugLevel); | ||
} else if (arcusFrontCache != null) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
다른 연산인 delete, flush 외에도 set 연산에서도 실패하면 기존에 info logging하고 있었습니다.
add 연산에서도 실패하면 동일하게 info logging 하면 될 것 같습니다.
boolean success = future.get(timeoutMilliSeconds, TimeUnit.MILLISECONDS);
if (success) {
if (arcusFrontCache != null) {
arcusFrontCache.set(arcusKey, value, frontExpireSeconds);
}
} else {
OperationStatus status = future.getStatus();
logger.info(....);
}
|
||
private static final OperationStatus NOT_STORED = new OperationStatus(false, "NOT_STORED", StatusCode.ERR_NOT_STORED); | ||
private static final OperationStatus NOT_FOUND = new OperationStatus(false, "NOT_FOUND", StatusCode.ERR_NOT_FOUND); | ||
private static final OperationStatus UNDEFINED = new OperationStatus(false, "UNDEFINED", StatusCode.UNDEFINED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
테스트 코드는 살펴보지 않았지만,
반드시 필요한 테스트만 추가하는 것이 좋습니다.
@oliviarla |
반영했습니다. |
@oliviarla @brido4125 리뷰 바랍니다. |
🔗 Related Issue
⌨️ What I did