Skip to content

perf(gax-grpc): skip metadata materialization when logging is disabled#12810

Open
rahul2393 wants to merge 3 commits intomainfrom
perf-optimization
Open

perf(gax-grpc): skip metadata materialization when logging is disabled#12810
rahul2393 wants to merge 3 commits intomainfrom
perf-optimization

Conversation

@rahul2393
Copy link
Copy Markdown
Contributor

@rahul2393 rahul2393 commented Apr 15, 2026

Summary

GrpcLoggingInterceptor was eagerly converting gRPC metadata into maps even when gax logging was disabled. That meant every RPC still paid metadata iteration/allocation cost before the logging gate.

This change guards request and response header materialization with LoggingUtils.isLoggingEnabled() so the disabled path avoids that work entirely.

Screenshot 2026-04-15 at 7 39 27 PM

@rahul2393 rahul2393 requested a review from a team as a code owner April 15, 2026 14:08
Copy link
Copy Markdown
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 updates GrpcLoggingInterceptor to check if logging is enabled before recording RPC and response headers, preventing unnecessary metadata materialization. The review feedback suggests ensuring test isolation in GrpcLoggingInterceptorTest by resetting the global logging state to true in the tearDown method, as the current implementation could negatively impact other tests.


@AfterEach
void tearDown() throws Exception {
setLoggingEnabled(false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The tearDown method sets the global logging state to false. Since LoggingUtils likely stores this state in a static field, this change will persist and potentially affect other tests in the same JVM. If other tests (such as testInterceptor_basic) expect logging to be enabled by default, they may fail or skip important logic when executed after this test. It is recommended to reset the state to true (or the original value) to ensure test isolation.

Suggested change
setLoggingEnabled(false);
setLoggingEnabled(true);

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.

2 participants