Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Change client request failed logging to info for 404 responses #791

Merged
merged 3 commits into from
Sep 16, 2024

Conversation

cookenox
Copy link
Contributor

@cookenox cookenox commented Sep 9, 2024

No description provided.

@@ -277,6 +277,19 @@ private <T> Mono<T> convertError(RequestBuilder fullReq, Throwable throwable) {
return Mono.error(throwable);
}

private static void logFailedRequest(Throwable throwable, String request) {
var logAsInfo = throwable instanceof WebException webException &&
Copy link
Member

@jepp3 jepp3 Sep 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for readability it is maybe nicer to not use short hand and not have a negative path ( "resource.not.found " != message ) , making it easier to read.

Level logLevel = Level.INFO;
if(throwable instanceof WebException webException) {
	var status = webException.getStatus();
	var errorMessage = webException.getError();

	if(NOT_FOUND.equals(status) && "resource.not.found".equals(errorMessage)) {
	     logLevel = Level.WARN;
	}
}

LOG.atLevel(logLevel).log("Failed request. Url: {}", request, throwable);

But im not sure it is better. but you got my blessing :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember now that you prefer more verbose style :)

What do you mean by "short hand"?

Also how do you suggest that I avoid using not? Your suggestion won't work out of the box since WARN should be the default. I guess I could and a case assigning WARN again if it is "resource.not.found" but not sure that is cleaner?

Copy link

@splitfeed splitfeed self-requested a review September 16, 2024 08:59
@softqwewasd softqwewasd merged commit c3064e1 into FortnoxAB:master Sep 16, 2024
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants