feat(gax): add utility for logging actionable errors#4144
feat(gax): add utility for logging actionable errors#4144westarle wants to merge 1 commit intogoogleapis:mainfrom
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces a new utility method logActionableError to LoggingUtils. My review focuses on two main points: the appropriateness of the logging level used and the absence of unit tests for the new functionality, which is required by the repository's contribution guidelines. I've provided specific comments with suggestions for improvement on both fronts.
| public static void logActionableError( | ||
| Map<String, Object> logContext, LoggerProvider loggerProvider, String message) { | ||
| if (loggingEnabled) { | ||
| org.slf4j.Logger logger = loggerProvider.getLogger(); | ||
| if (logger.isInfoEnabled()) { | ||
| Slf4jUtils.log(logger, org.slf4j.event.Level.INFO, logContext, message); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
The method logActionableError logs messages at the INFO level. Given the name of the method, it would be more appropriate to log these messages at a WARN or ERROR level. Logging actionable errors as INFO might cause them to be overlooked in production environments where log levels are filtered. Consider using the WARN level for these messages.
| public static void logActionableError( | |
| Map<String, Object> logContext, LoggerProvider loggerProvider, String message) { | |
| if (loggingEnabled) { | |
| org.slf4j.Logger logger = loggerProvider.getLogger(); | |
| if (logger.isInfoEnabled()) { | |
| Slf4jUtils.log(logger, org.slf4j.event.Level.INFO, logContext, message); | |
| } | |
| } | |
| } | |
| public static void logActionableError( | |
| Map<String, Object> logContext, LoggerProvider loggerProvider, String message) { | |
| if (loggingEnabled) { | |
| org.slf4j.Logger logger = loggerProvider.getLogger(); | |
| if (logger.isWarnEnabled()) { | |
| Slf4jUtils.log(logger, org.slf4j.event.Level.WARN, logContext, message); | |
| } | |
| } | |
| } |
| * @param loggerProvider The provider used to obtain the logger. | ||
| * @param message The human-readable error message. | ||
| */ | ||
| public static void logActionableError( |
There was a problem hiding this comment.
According to the repository's testing guidelines, new logic in the gax module must be accompanied by unit tests. This new public method logActionableError should have corresponding tests in LoggingUtilsTest to ensure its correctness and prevent future regressions.
References
- The repository style guide (line 75) mandates that changes in the
gaxmodule must include traditional unit tests. (link)
3722925 to
6ac4725
Compare
6ac4725 to
bbbdfcf
Compare
dfa205a to
bbbdfcf
Compare
bbbdfcf to
27b0fac
Compare
112f855 to
827b16b
Compare
999dec3 to
874941b
Compare
This PR introduces the
logActionableErrorutility method to the coreLoggingUtilsclass within thegaxmodule.This will be used by an upcoming gRPC interceptor (
gax-grpc) and HTTP/JSON interceptor (gax-httpjson).