rls, grpc: inherit parent channel stats handlers and interceptors on the RLS control channel - #9362
Closed
sushanb wants to merge 2 commits into
Closed
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #9362 +/- ##
==========================================
- Coverage 87.45% 87.43% -0.02%
==========================================
Files 425 425
Lines 30297 30338 +41
==========================================
+ Hits 26496 26527 +31
- Misses 3801 3811 +10
🚀 New features to boost your workflow:
|
…pers Several types in the balancer tree wrap a balancer.ClientConn by anonymously embedding it. Add an Unwrap() balancer.ClientConn method to each of them so that gRPC-internal callers can walk up the wrapping chain to reach the underlying parent ClientConn. This is the mirror-image contract of what errors.Unwrap provides for error trees. The method is a one-liner returning the embedded field, and doesn't change any existing behavior. It exists so a follow-up change can rely on it to inherit parent-channel telemetry (stats handlers and interceptors) onto balancer-owned control channels (e.g. the RLS control channel) without resorting to reflection over private fields. Wrappers touched: internal/balancer/gracefulswitch.balancerWrapper internal/balancergroup.subBalancerWrapper internal/xds/balancer/clusterimpl.clusterImplBalancer internal/xds/balancer/outlierdetection.outlierDetectionBalancer internal/xds/balancer/priority.ignoreResolveNowClientConn balancer/grpclb.lbCacheClientConn balancer/ringhash.ringhashBalancer RELEASE NOTES: none
…the RLS control channel RouteLookup RPCs issued on the RLS balancer's control channel were invisible to any stats handler configured on the parent ClientConn (e.g. OpenTelemetry's grpc.client.attempt.duration histogram), because the control channel was created via a bare grpc.NewClient call that had no way to see the parent channel's stats handlers or client interceptors. Introduce an internal hook, NewChannelForBalancer, that creates a new ClientConn while inheriting the parent's stats handlers and unary/stream interceptors (single and chained). The parent is reached by walking the balancer.ClientConn wrapping chain using the Unwrap() balancer.ClientConn contract that every wrapper in the tree now implements (added in a prior change). A seen-set guards against cycles. RLS now dials via this hook instead of grpc.NewClient. Verified end-to-end against a real Bigtable DirectPath workload: RouteLookup attempts to dns:///bigtablerls.googleapis.com show up in grpc.client.attempt.duration with method, target, and status labels populated correctly. Regression test added in balancer/rls/metrics_test.go. RELEASE NOTES: * rls: RouteLookup RPCs issued on the RLS balancer's control channel now inherit stats handlers and client interceptors configured on the parent ClientConn, so per-attempt telemetry (e.g. grpc.client.attempt.duration) covers RouteLookup RPCs.
sushanb
force-pushed
the
fix/rls-control-channel-inherit-parent-telemetry
branch
from
August 25, 2026 03:45
c81f28e to
069665d
Compare
sushanb
marked this pull request as draft
August 25, 2026 03:56
Contributor
Author
|
Converting to draft while I re-implement the fix to conform to gRFC A110 (Child Channel Options). This PR's approach (auto-inheriting the parent channel's stats handlers + interceptors via an internal walk) violates A110's explicit rule that |
2 tasks
Member
|
We generally do not prefer keeping draft PRs. Please re-open once the implementation is done and ready for review. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RouteLookup RPCs issued on the RLS balancer's control channel were invisible to any stats handler configured on the parent
ClientConn(e.g. OpenTelemetry'sgrpc.client.attempt.durationhistogram), because the control channel was created via a baregrpc.NewClientcall that had no way to see the parent channel's stats handlers or client interceptors.Approach
Introduce an internal hook
internal.NewChannelForBalancer(populated inclientconn.goinit, mirroringSubscribeToConnectivityStateChangesand other existing internal-hook patterns). It creates a newClientConnwhile inheriting the parent's stats handlers and unary/stream interceptors (single and chained).The parent is reached by walking the
balancer.ClientConnwrapping chain via theUnwrap() balancer.ClientConncontract that every embedding wrapper implements after #9363. Aseenset guards against cycles. No reflection — all wrapper hops are explicit.RLS now dials via this hook (
balancer/rls/control_channel.go) instead ofgrpc.NewClient;rlsBalancerpasses itsb.ccthrough.No public API change
No new fields on
balancer.BuildOptions, no new methods onbalancer.ClientConn— the mechanism is entirely internal, keeping the API surface stable.Verification
./balancer/...,./stats/opentelemetry/...,./internal/balancer/...,./internal/balancergroup/..., root grpc.TestRLSControlChannelAttemptDurationMetricinbalancer/rls/metrics_test.goasserts agrpc.client.attempt.durationdata point is recorded withgrpc.method=grpc.lookup.v1.RouteLookupService/RouteLookupafter a real dial withopentelemetry.DialOptiontriggers a RouteLookup via the RLS balancer.dns:///bigtablerls.googleapis.comshow up ingrpc.client.attempt.durationwith method, target, and status labels populated correctly.Test plan
go test ./...passes in CIRELEASE NOTES: