@@ -12,7 +12,7 @@ import { isNonNullable } from '../shared/utilities/tsUtils'
12
12
import { ToolIdStateKey } from '../shared/globalState'
13
13
import { Connection , getTelemetryMetadataForConn , SsoConnection , StatefulConnection } from './connection'
14
14
import { indent } from '../shared/utilities/textUtilities'
15
- import { AuthStatus , telemetry } from '../shared/telemetry/telemetry'
15
+ import { AuthModifyConnection , AuthStatus , Span , telemetry } from '../shared/telemetry/telemetry'
16
16
import { asStringifiedStack } from '../shared/telemetry/spans'
17
17
import { withTelemetryContext } from '../shared/telemetry/util'
18
18
import { isNetworkError } from '../shared/errors'
@@ -307,7 +307,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
307
307
connectionState : 'undefined' ,
308
308
} )
309
309
await this . auth . tryAutoConnect ( )
310
- this . #savedConnection = await this . _loadSavedConnection ( )
310
+ this . #savedConnection = await this . _loadSavedConnection ( span )
311
311
this . #onDidChangeActiveConnection. fire ( this . activeConnection )
312
312
313
313
const conn = this . #savedConnection
@@ -328,7 +328,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
328
328
/**
329
329
* Provides telemetry if called by restoreConnection() (or another auth_modifyConnection context)
330
330
*/
331
- private async _loadSavedConnection ( ) {
331
+ private async _loadSavedConnection ( span : Span < AuthModifyConnection > ) {
332
332
const id = this . getStateConnectionId ( )
333
333
if ( id === undefined ) {
334
334
return
@@ -349,7 +349,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
349
349
let connectionState = this . auth . getConnectionState ( conn )
350
350
351
351
// This function is expected to be called in the context of restoreConnection()
352
- telemetry . auth_modifyConnection . record ( {
352
+ span . record ( {
353
353
connectionState,
354
354
authStatus : getAuthStatus ( connectionState ) ,
355
355
} )
@@ -358,7 +358,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
358
358
await this . auth . refreshConnectionState ( conn )
359
359
360
360
connectionState = this . auth . getConnectionState ( conn )
361
- telemetry . auth_modifyConnection . record ( {
361
+ span . record ( {
362
362
connectionState,
363
363
authStatus : getAuthStatus ( connectionState ) ,
364
364
} )
@@ -367,7 +367,7 @@ export class SecondaryAuth<T extends Connection = Connection> {
367
367
// If updating the state fails, then we should delegate downstream to handle getting the proper state.
368
368
getLogger ( ) . error ( 'loadSavedConnection: Failed to refresh connection state: %s' , err )
369
369
if ( isNetworkError ( err ) && connectionState === 'valid' ) {
370
- telemetry . auth_modifyConnection . record ( {
370
+ span . record ( {
371
371
authStatus : 'connectedWithNetworkError' ,
372
372
} )
373
373
}
0 commit comments