fix(spanner): update DirectPath detection logic to use ALTS credentials#14288
fix(spanner): update DirectPath detection logic to use ALTS credentials#14288sakthivelmanii merged 2 commits intomainfrom
Conversation
Switched the directpath_used metric logic to assert alts.AuthInfo on the gRPC peer context. This improves reliability over previous IP prefix matching, mapping more closely to standard gRPC practices across evolving DirectPath networks.
There was a problem hiding this comment.
Code Review
This pull request updates the DirectPath detection logic to use ALTS authentication information instead of IP address prefixes. The changes involve removing hardcoded IP prefixes and updating the isDirectPathRemoteAddress and setDirectPathUsed functions to perform type assertions on the peer's AuthInfo. Additionally, unit tests have been added to verify the new detection logic. One review comment suggests simplifying a redundant nil check in the metrics logic, as type assertions on nil interfaces are safe in Go.
| if ok && peerInfo.AuthInfo != nil { | ||
| if _, isALTS := peerInfo.AuthInfo.(alts.AuthInfo); isALTS { | ||
| a.directPathUsed = true | ||
| } | ||
| } |
There was a problem hiding this comment.
The check peerInfo.AuthInfo != nil is redundant. The type assertion _, isALTS := peerInfo.AuthInfo.(alts.AuthInfo) will safely handle the case where peerInfo.AuthInfo is nil by setting isALTS to false. You can simplify the condition.
| if ok && peerInfo.AuthInfo != nil { | |
| if _, isALTS := peerInfo.AuthInfo.(alts.AuthInfo); isALTS { | |
| a.directPathUsed = true | |
| } | |
| } | |
| if ok { | |
| if _, isALTS := peerInfo.AuthInfo.(alts.AuthInfo); isALTS { | |
| a.directPathUsed = true | |
| } | |
| } |
3ff475d to
bcae041
Compare
PR created by the Librarian CLI to initialize a release. Merging this PR will auto trigger a release. Librarian Version: v0.10.1 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/librarian-go@sha256:b04b076f5eedbb5546bd6fc1404969dd3698c8b19c0f34ae815a84ae735a606a <details><summary>spanner: v1.90.0</summary> ## [v1.90.0](spanner/v1.89.0...spanner/v1.90.0) (2026-04-14) ### Features * feat(spanner): add EnableDirectAccess field to ClientConfig (#14287) ([6adf5b7](6adf5b7)) * feat(spanner): Switch to using builtin open telemetry for EEF (#14193)([751febd](751febd)) * feat(spanner): complete location-aware routing resilience and observability (#14418 ) ([77aa4df](77aa4df)) ### Bug Fixes * fix(spanner): set gauge metric start time to match end time (#14289) ([e0760b5](e0760b5)) * fix(spanner): update DirectPath detection logic to use ALTS credentials(#14288)([3cd5716](3cd5716)) </details>
Switched the directpath_used metric logic to assert alts.AuthInfo on the gRPC peer context. This improves reliability over previous IP prefix matching, mapping more closely to standard gRPC practices across evolving DirectPath networks.