Skip to content

perf(spanner): bypass gRPC message interception in metrics interceptor - #9306

Open
olavloite wants to merge 1 commit into
mainfrom
spanner-remove-noop-interceptor
Open

olavloite wants to merge 1 commit into
mainfrom
spanner-remove-noop-interceptor

Conversation

@olavloite

Copy link
Copy Markdown
Contributor

MetricInterceptor previously defined pass-through requester hooks (sendMessage, halfClose, cancel) and used a 2-argument Listener interface. This caused @grpc/grpc-js to wrap every call in an InterceptingListenerImpl, adding a closure allocation and state machine bookkeeping for every streamed chunk.

This change implements InterceptingListener directly and removes the redundant requester hooks. Because the listener methods now take a single argument, @grpc/grpc-js recognizes the listener as synchronous and forwards incoming streaming messages directly to downstream handlers.

MetricInterceptor previously defined pass-through requester hooks (sendMessage,
halfClose, cancel) and used a 2-argument Listener interface. This caused
@grpc/grpc-js to wrap every call in an InterceptingListenerImpl, adding a
closure allocation and state machine bookkeeping for every streamed chunk.

This change implements InterceptingListener directly and removes the redundant
requester hooks. Because the listener methods now take a single argument,
@grpc/grpc-js recognizes the listener as synchronous and forwards incoming
streaming messages directly to downstream handlers.
@olavloite
olavloite requested a review from a team as a code owner September 13, 2026 05:30
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Sep 13, 2026

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

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.

Code Review

This pull request refactors the MetricInterceptor to use typed InterceptingListener from @grpc/grpc-js and removes redundant requester hooks, accompanied by new unit tests. The feedback identifies a potential ReferenceError in the new tests where Status.CANCELLED is referenced without being imported, and suggests using grpc.status.CANCELLED instead.

Comment thread handwritten/spanner/test/metrics/interceptor.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the Spanner API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant