Skip to content
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

SLING-11748 - Improve logging output of HTTP retries in testing clients #42

Merged
merged 3 commits into from
Feb 7, 2023

Conversation

marcpf
Copy link
Contributor

@marcpf marcpf commented Jan 11, 2023

https://issues.apache.org/jira/browse/SLING-11748

Proposal for improving the HTTP retry log output in the testing clients.

Current Output (from unit test):

Request retry needed due to service unavailable response
Response headers contained:
Header Date:Wed, 11 Jan 2023 08:36:43 GMT
Header Server:TEST/1.1
Header Content-Length:8
Header Content-Type:text/plain; charset=ISO-8859-1
Header Connection:Keep-Alive
Response content: TEST_NOK

Proposed output with this PR (from unit test):

Request retry condition met: [count=1/4], [expected-codes=[200]], [retry-codes=[500, 503]]
Request: GET /test/internalerror/resource HTTP/1.1 [Host: 127.0.0.1:32953, Connection: Keep-Alive, User-Agent: Java, Accept-Encoding: gzip,deflate, Authorization: Basic dXNlcjpwYXNz]
Response: HTTP/1.1 500 Internal Server Error [Date: Wed, 11 Jan 2023 08:39:59 GMT, Server: TEST/1.1, Content-Length: 8, Content-Type: text/plain; charset=ISO-8859-1, Connection: Keep-Alive, ]
Response Body: TEST_NOK

LOG.warn("Request retry condition met: [count={}/{}], [expected-codes={}], [retry-codes={}]",
executionCount, SystemPropertiesConfig.getHttpRetries(), expectedStatus, SystemPropertiesConfig.getHttpRetriesErrorCodes());
LOG.warn("Request: {}", getRequestDetails(context));
LOG.warn("Response: {}", getResponseDetails(response));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do write out this information in 3 distinct log messages? I would prefer a single log message, which is then much easier to capture than 3 subsequent messages.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @joerghoh. I think 3 log lines is a good middle way. We had a log line per request/response header before. I as well think its easier to deal with in Splunk queries.

@sonarcloud
Copy link

sonarcloud bot commented Jan 26, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

91.7% 91.7% Coverage
0.0% 0.0% Duplication

@marcpf
Copy link
Contributor Author

marcpf commented Feb 3, 2023

@dulvac, @joerghoh, quickly wanted to check with you what the status is with my PR. Do you consider it to merge?

@dulvac
Copy link
Member

dulvac commented Feb 7, 2023

I assume silent consensus so merging :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants