Skip to content

Commit f971db1

Browse files
authored
telemetry(auth): report request IDs when refreshing a token fails (#3379)
## Problem Some users run into obscure service errors that do not surface useful information in the error messages ## Solution Report the request ID in telemetry so we can investigate on the service-side
1 parent 7aebb01 commit f971db1

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/credentials/sso/ssoAccessTokenProvider.ts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ import { OidcClient } from './clients'
1717
import { loadOr } from '../../shared/utilities/cacheUtils'
1818
import { getRequestId, getTelemetryReason, getTelemetryResult, isClientFault, ToolkitError } from '../../shared/errors'
1919
import { getLogger } from '../../shared/logger'
20-
import { telemetry } from '../../shared/telemetry/telemetry'
21-
import { DevSettings } from '../../shared/settings'
20+
import { AwsRefreshCredentials, telemetry } from '../../shared/telemetry/telemetry'
2221
import { getIdeProperties, isCloud9 } from '../../shared/extensionUtilities'
2322

2423
const clientRegistrationType = 'public'
@@ -124,18 +123,14 @@ export class SsoAccessTokenProvider {
124123

125124
return refreshed
126125
} catch (err) {
127-
const span = telemetry.aws_refreshCredentials
128-
if (DevSettings.instance.get('reportRequestIds', false)) {
129-
span.record({ requestId: getRequestId(err) } as any)
130-
}
131-
132-
span.emit({
126+
telemetry.aws_refreshCredentials.emit({
133127
result: getTelemetryResult(err),
134128
reason: getTelemetryReason(err),
129+
requestId: getRequestId(err),
135130
sessionDuration: getSessionDuration(this.tokenCacheKey),
136131
credentialType: 'bearerToken',
137132
credentialSourceId: this.profile.startUrl === builderIdStartUrl ? 'awsId' : 'iamIdentityCenter',
138-
})
133+
} as AwsRefreshCredentials)
139134

140135
if (err instanceof SSOOIDCServiceException && isClientFault(err)) {
141136
await this.cache.token.clear(this.tokenCacheKey)

src/shared/settings.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@ const devSettings = {
584584
forceInstallTools: Boolean,
585585
telemetryEndpoint: String,
586586
telemetryUserPool: String,
587-
reportRequestIds: Boolean,
588587
renderDebugDetails: Boolean,
589588
endpoints: Record(String, String),
590589
cawsStage: String,

0 commit comments

Comments
 (0)