Skip to content

feat(gax): add utility for logging actionable errors#4144

Open
westarle wants to merge 1 commit intogoogleapis:mainfrom
westarle:feat/actionable-errors-logging-utils
Open

feat(gax): add utility for logging actionable errors#4144
westarle wants to merge 1 commit intogoogleapis:mainfrom
westarle:feat/actionable-errors-logging-utils

Conversation

@westarle
Copy link
Contributor

This PR introduces the logActionableError utility method to the core LoggingUtils class within the gax module.

This will be used by an upcoming gRPC interceptor (gax-grpc) and HTTP/JSON interceptor (gax-httpjson).

@product-auto-label product-auto-label bot added the size: s Pull request size is small. label Mar 15, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello, 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 gax module's logging capabilities by introducing a new utility method designed for logging actionable errors with structured context. This addition is foundational for future gRPC and HTTP/JSON interceptors, enabling more informative and standardized error reporting across the system.

Highlights

  • New Logging Utility: Introduced the logActionableError static method to the LoggingUtils class, enabling structured logging of actionable error messages.
Changelog
  • gax-java/gax/src/main/java/com/google/api/gax/logging/LoggingUtils.java
    • Added the logActionableError static method for structured error logging.
Activity
  • No specific activity (comments, reviews, progress updates) was found in the provided context.
Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

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.

Comment on lines +137 to +145
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);
}
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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.

Suggested change
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(
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

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
  1. The repository style guide (line 75) mandates that changes in the gax module must include traditional unit tests. (link)

@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from 3722925 to 6ac4725 Compare March 15, 2026 02:43
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Mar 15, 2026
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from 6ac4725 to bbbdfcf Compare March 15, 2026 02:45
@product-auto-label product-auto-label bot added size: s Pull request size is small. size: m Pull request size is medium. and removed size: m Pull request size is medium. size: s Pull request size is small. labels Mar 15, 2026
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from dfa205a to bbbdfcf Compare March 15, 2026 03:05
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: m Pull request size is medium. labels Mar 15, 2026
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from bbbdfcf to 27b0fac Compare March 15, 2026 03:10
@product-auto-label product-auto-label bot added size: m Pull request size is medium. and removed size: s Pull request size is small. labels Mar 15, 2026
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from 112f855 to 827b16b Compare March 15, 2026 03:23
@westarle westarle force-pushed the feat/actionable-errors-logging-utils branch from 999dec3 to 874941b Compare March 15, 2026 03:48
@westarle westarle marked this pull request as ready for review March 15, 2026 04:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size: m Pull request size is medium.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant