@@ -413,7 +413,7 @@ func NewBigtableChannelPool(ctx context.Context, connPoolSize int, strategy btop
413413
414414 if pool .directAccessDialer != nil {
415415 var isDirectAccess bool
416- if firstConn , isDirectAccess = pool .checkIfDirectAccessIsAvailable (); isDirectAccess {
416+ if firstConn , isDirectAccess = pool .checkIfDirectAccessCompatible (); isDirectAccess {
417417 btopt .Debugf (pool .logger , "bigtable_connpool: Direct Access is available. Using Direct Access now." )
418418 factoryDial = pool .directAccessDialer
419419 factoryFeatureFlagsMD = pool .directAccessFeatureFlagsMD
@@ -508,9 +508,9 @@ func NewBigtableChannelPool(ctx context.Context, connPoolSize int, strategy btop
508508 return pool , nil
509509}
510510
511- // checkIfDirectAccessIsAvailable attempts to create a single connection using the directAccessDialer,
511+ // checkIfDirectAccessCompatible attempts to create a single connection using the directAccessDialer,
512512// primes it, and checks if direct access was successful
513- func (p * BigtableChannelPool ) checkIfDirectAccessIsAvailable () (* BigtableConn , bool ) {
513+ func (p * BigtableChannelPool ) checkIfDirectAccessCompatible () (* BigtableConn , bool ) {
514514 conn , err := p .directAccessDialer ()
515515 if err != nil {
516516 btopt .Debugf (p .logger , "bigtable_connpool: Direct Access failed: %v" , err )
@@ -521,23 +521,25 @@ func (p *BigtableChannelPool) checkIfDirectAccessIsAvailable() (*BigtableConn, b
521521 if err != nil {
522522 btopt .Debugf (p .logger , "bigtable_connpool: Prime() failed during Direct Access check: %v" , err )
523523 conn .Close ()
524- p .reportDirectAccessMetric (false )
524+ p .reportDirectAccessMetric (false , "" )
525525 return nil , false
526526 }
527527
528528 if conn .isALTSConn .Load () {
529- p .reportDirectAccessMetric (true )
529+ ipProtocol := conn .ipProtocol ()
530+ p .reportDirectAccessMetric (true , ipProtocol )
530531 return conn , true
531532 }
532533
533534 // If not ALTS, discard
534535 conn .Close ()
535- p .reportDirectAccessMetric (false )
536+ // sent empty ip protocol
537+ p .reportDirectAccessMetric (false , "" )
536538 return nil , false
537539}
538540
539541// reportDirectAccessMetric records the direct_access/compatible metric.
540- func (p * BigtableChannelPool ) reportDirectAccessMetric (isEligible bool ) {
542+ func (p * BigtableChannelPool ) reportDirectAccessMetric (isEligible bool , ipPreference string ) {
541543 // Check if the instrument was successfully created during pool initialization
542544 if p .daEligibleGauge == nil {
543545 return
@@ -546,7 +548,8 @@ func (p *BigtableChannelPool) reportDirectAccessMetric(isEligible bool) {
546548 if isEligible {
547549 val = 1
548550 }
549- p .daEligibleGauge .Record (p .poolCtx , val )
551+ p .daEligibleGauge .Record (p .poolCtx , val , metric .WithAttributes (
552+ attribute .String ("ip_preference" , ipPreference )))
550553}
551554
552555func (p * BigtableChannelPool ) recordClientStartUp (clientCreationTimestamp time.Time , transportType string ) {
0 commit comments