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

Improve Jira logging #5351

Merged
merged 11 commits into from
Jan 30, 2025
Merged

Conversation

Galactus22625
Copy link
Member

Description

prevent over logging stack traces in jira source

Check List

  • New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: Maxwell Brown <[email protected]>
@@ -75,7 +75,7 @@ public LeaderProgressState convertToPartitionState(final String serializedPartit
try {
return objectMapper.readValue(serializedPartitionProgressState, LeaderProgressState.class);
} catch (final JsonProcessingException e) {
LOG.error("Unable to convert string to partition progress state class ", e);
LOG.error("Unable to convert string to partition progress state class due to {}", e.getMessage());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we print the String partition progress state as well here?

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

san81
san81 previously approved these changes Jan 23, 2025
Copy link
Collaborator

@san81 san81 left a comment

Choose a reason for hiding this comment

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

Thank you for this clean up

@@ -38,7 +38,7 @@ public static InetAddress getInetAddress(String url) {
try {
return InetAddress.getByName(new URL(url).getHost());
} catch (UnknownHostException | MalformedURLException e) {
log.error(INVALID_URL, e);
log.error(INVALID_URL + " : {}", url);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
log.error(INVALID_URL + " : {}", url);
log.error("{}: {}", INVALID_URL, url);

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

authConfig.renewCredentials();
} else if (statusCode == HttpStatus.TOO_MANY_REQUESTS) {
log.error(NOISY, "Hitting API rate limit. Backing off with sleep timer.", ex);
log.error("Hitting API rate limit. Backing off with sleep timer.");
Copy link
Member

Choose a reason for hiding this comment

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

Should this be noisy?

Copy link
Member Author

@Galactus22625 Galactus22625 Jan 24, 2025

Choose a reason for hiding this comment

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

I think its not needed because it's only one line and retries are capped at 6

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, will make noisy

log.error(NOISY, "Hitting API rate limit. Backing off with sleep timer.", ex);
log.error("Hitting API rate limit. Backing off with sleep timer.");
} else {
log.error(NOISY, "Exception: ", ex);
Copy link
Member

Choose a reason for hiding this comment

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

Provide a more useful exception line here. Also, we know that this is an HTTP client status code when we get here. It is just one we don't know.

For example:

log.error(NOISY, "Received an unexpected status code when requesting from Jira. statusCode={}", statusCode);

Copy link
Member Author

Choose a reason for hiding this comment

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

ok

@@ -119,19 +119,21 @@ private <T> ResponseEntity<T> invokeRestApi(URI uri, Class<T> responseType) thro
} catch (HttpClientErrorException ex) {
Copy link
Member

Choose a reason for hiding this comment

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

What happens if another type of exception is thrown here? This will throw it back. Do we have other error handling for that?

Also, we appear to not have error handling for 5xx errors.

Copy link
Member Author

Choose a reason for hiding this comment

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

added error logging for unknown exception, added error handling for some 5xx errors

san81
san81 previously approved these changes Jan 24, 2025
Signed-off-by: Maxwell Brown <[email protected]>
san81
san81 previously approved these changes Jan 27, 2025
Signed-off-by: Maxwell Brown <[email protected]>
san81
san81 previously approved these changes Jan 29, 2025
Signed-off-by: Maxwell Brown <[email protected]>
if (statusCode == HttpStatus.FORBIDDEN) {
throw new UnAuthorizedException(statusMessage);
} else if (statusCode == HttpStatus.UNAUTHORIZED) {
log.error("Token expired. We will try to renew the tokens now.");
log.error(NOISY, "Token expired. We will try to renew the tokens now.");
Copy link
Member

Choose a reason for hiding this comment

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

I think we are expecting this to happen right? So every hour (or whatever the token refresh time is) we hit this. If this is the case, it really should be a warning.

Copy link
Member Author

Choose a reason for hiding this comment

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

changing to log.warn

authConfig.renewCredentials();
} else if (statusCode == HttpStatus.TOO_MANY_REQUESTS) {
log.error("Hitting API rate limit. Backing off with sleep timer.");
log.error(NOISY, "Hitting API rate limit. Backing off with sleep timer for {} seconds.", RETRY_ATTEMPT_SLEEP_TIME.get(retryCount));
Copy link
Member

Choose a reason for hiding this comment

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

You could consolidate these.

else if(statusCode == HttpStatus.SERVICE_UNAVAILABLE || statusCode == GATEWAY_TIMEOUT ...) {
  log.error(NOISY, "Received {}. Will retry after backing off with sleep timer for {} seconds.", statusCode, RETRY_ATTEMPT_SLEEP_TIME.get(retryCount));
}

Copy link
Member Author

Choose a reason for hiding this comment

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

consolidated

Signed-off-by: Maxwell Brown <[email protected]>
dlvenable
dlvenable previously approved these changes Jan 30, 2025
san81
san81 previously approved these changes Jan 30, 2025
@Galactus22625 Galactus22625 dismissed stale reviews from san81 and dlvenable via aa7947f January 30, 2025 18:02
@dlvenable dlvenable merged commit 414a7c9 into opensearch-project:main Jan 30, 2025
43 of 47 checks passed
@Galactus22625 Galactus22625 deleted the jira-overlogging branch January 30, 2025 19: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.

3 participants