@@ -12,7 +12,7 @@ import { isNonNullable } from '../shared/utilities/tsUtils'
1212import { ToolIdStateKey } from '../shared/globalState'
1313import { Connection , getTelemetryMetadataForConn , SsoConnection , StatefulConnection } from './connection'
1414import { indent } from '../shared/utilities/textUtilities'
15- import { AuthStatus , telemetry } from '../shared/telemetry/telemetry'
15+ import { AuthModifyConnection , AuthStatus , Span , telemetry } from '../shared/telemetry/telemetry'
1616import { asStringifiedStack } from '../shared/telemetry/spans'
1717import { withTelemetryContext } from '../shared/telemetry/util'
1818import { isNetworkError } from '../shared/errors'
@@ -307,7 +307,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
307307 connectionState : 'undefined' ,
308308 } )
309309 await this . auth . tryAutoConnect ( )
310- this . #savedConnection = await this . _loadSavedConnection ( )
310+ this . #savedConnection = await this . _loadSavedConnection ( span )
311311 this . #onDidChangeActiveConnection. fire ( this . activeConnection )
312312
313313 const conn = this . #savedConnection
@@ -328,7 +328,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
328328 /**
329329 * Provides telemetry if called by restoreConnection() (or another auth_modifyConnection context)
330330 */
331- private async _loadSavedConnection ( ) {
331+ private async _loadSavedConnection ( span : Span < AuthModifyConnection > ) {
332332 const id = this . getStateConnectionId ( )
333333 if ( id === undefined ) {
334334 return
@@ -349,7 +349,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
349349 let connectionState = this . auth . getConnectionState ( conn )
350350
351351 // This function is expected to be called in the context of restoreConnection()
352- telemetry . auth_modifyConnection . record ( {
352+ span . record ( {
353353 connectionState,
354354 authStatus : getAuthStatus ( connectionState ) ,
355355 } )
@@ -358,7 +358,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
358358 await this . auth . refreshConnectionState ( conn )
359359
360360 connectionState = this . auth . getConnectionState ( conn )
361- telemetry . auth_modifyConnection . record ( {
361+ span . record ( {
362362 connectionState,
363363 authStatus : getAuthStatus ( connectionState ) ,
364364 } )
@@ -367,7 +367,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
367367 // If updating the state fails, then we should delegate downstream to handle getting the proper state.
368368 getLogger ( ) . error ( 'loadSavedConnection: Failed to refresh connection state: %s' , err )
369369 if ( isNetworkError ( err ) && connectionState === 'valid' ) {
370- telemetry . auth_modifyConnection . record ( {
370+ span . record ( {
371371 authStatus : 'connectedWithNetworkError' ,
372372 } )
373373 }
0 commit comments