Skip to content

fix(spanner): update DirectPath detection logic to use ALTS credentials#14288

Merged
sakthivelmanii merged 2 commits intomainfrom
fix/directpath-alts-detection
Mar 30, 2026
Merged

fix(spanner): update DirectPath detection logic to use ALTS credentials#14288
sakthivelmanii merged 2 commits intomainfrom
fix/directpath-alts-detection

Conversation

@sakthivelmanii
Copy link
Copy Markdown
Contributor

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.

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.
@sakthivelmanii sakthivelmanii requested review from a team as code owners March 29, 2026 17:36
@product-auto-label product-auto-label Bot added the api: spanner Issues related to the Spanner API. label Mar 29, 2026
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 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.

Comment thread spanner/metrics.go Outdated
Comment on lines 537 to 541
if ok && peerInfo.AuthInfo != nil {
if _, isALTS := peerInfo.AuthInfo.(alts.AuthInfo); isALTS {
a.directPathUsed = true
}
}
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 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.

Suggested change
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
}
}

@sakthivelmanii sakthivelmanii force-pushed the fix/directpath-alts-detection branch from 3ff475d to bcae041 Compare March 29, 2026 18:42
@sakthivelmanii sakthivelmanii merged commit 3cd5716 into main Mar 30, 2026
10 checks passed
@sakthivelmanii sakthivelmanii deleted the fix/directpath-alts-detection branch March 30, 2026 05:53
rahul2393 added a commit that referenced this pull request Apr 14, 2026
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>
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.

2 participants