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

Reduce number of log messages produced by default Client #14

Merged

Conversation

chrisnovakovic
Copy link
Collaborator

@chrisnovakovic chrisnovakovic commented Mar 12, 2024

retryablehttp.Client logs excessively (one Printf to stdout per HTTP request) unless a retryablehttp.LeveledLogger is configured as its logger. Add a logger that implements retryablehttp.LeveledLogger, whose verbosity defaults to INFO and can be controlled via the VERBOSITY environment variable, and use it as the logger for the default Client.

The logger increases the level of some messages produced by retryablehttp.Client, in particular those that report when requests are about to be retried, for the sake of visibility.

`retryablehttp.Client` logs excessively (one `Printf` to stdout per HTTP
request) unless a `retryablehttp.LeveledLogger` is configured as its
logger. Add a logger that implements `retryablehttp.LeveledLogger`,
whose verbosity defaults to `INFO` and can be controlled via the
`VERBOSITY` environment variable.

The logger increases the level of some messages produced by
`retryablehttp.Client`, in particular those that report when requests
are about to be retried, for the sake of visibility.
@chrisnovakovic
Copy link
Collaborator Author

chrisnovakovic commented Mar 12, 2024

The test suite provides the best example of the reduction in log spam that this PR achieves.

Before:

=== RUN   TestIssueService_GetWatchers
2024/03/12 17:21:22 [DEBUG] GET http://127.0.0.1:45057/rest/api/2/issue/10002/watchers
2024/03/12 17:21:22 [DEBUG] GET http://127.0.0.1:45057/rest/api/2/user?accountId=000000000000000000000000
--- PASS: TestIssueService_GetWatchers (0.00s)
=== RUN   TestClient_Do_TooManyRequests
2024/03/12 17:21:22 [DEBUG] GET http://127.0.0.1:45433/
2024/03/12 17:21:22 [DEBUG] GET http://127.0.0.1:45433/ (status: 429): retrying in 3s (4 left)
--- PASS: TestClient_Do_TooManyRequests (3.01s)

After:

=== RUN   TestIssueService_GetWatchers
--- PASS: TestIssueService_GetWatchers (0.00s)
=== RUN   TestClient_Do_TooManyRequests
time=2024-03-12T17:03:12.482Z level=WARN msg="retrying request" request="GET http://127.0.0.1:36983/ (status: 429)" timeout=3s remaining=4
--- PASS: TestClient_Do_TooManyRequests (3.00s)

@chrisnovakovic chrisnovakovic changed the title Reduce default verbosity of logs produced by default client Reduce number of log messages produced by default client Mar 12, 2024
@chrisnovakovic chrisnovakovic changed the title Reduce number of log messages produced by default client Reduce number of log messages produced by default Client Mar 13, 2024
@chrisnovakovic chrisnovakovic merged commit 99b9dae into thought-machine:v1 Mar 13, 2024
6 checks passed
@chrisnovakovic chrisnovakovic deleted the retryablehttp-leveledlogger branch March 13, 2024 09:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant