@azure/msal-common 14.7.1 → 14.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/AccountInfo.mjs +1 -1
- package/dist/account/AuthToken.mjs +1 -1
- package/dist/account/CcsCredential.mjs +1 -1
- package/dist/account/ClientInfo.mjs +1 -1
- package/dist/account/TokenClaims.mjs +1 -1
- package/dist/authority/Authority.mjs +1 -1
- package/dist/authority/AuthorityFactory.mjs +1 -1
- package/dist/authority/AuthorityMetadata.mjs +1 -1
- package/dist/authority/AuthorityOptions.mjs +1 -1
- package/dist/authority/AuthorityType.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.mjs +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.mjs +1 -1
- package/dist/authority/OpenIdConfigResponse.mjs +1 -1
- package/dist/authority/ProtocolMode.mjs +1 -1
- package/dist/authority/RegionDiscovery.mjs +1 -1
- package/dist/cache/CacheManager.d.ts +0 -12
- package/dist/cache/CacheManager.d.ts.map +1 -1
- package/dist/cache/CacheManager.mjs +5 -14
- package/dist/cache/CacheManager.mjs.map +1 -1
- package/dist/cache/entities/AccountEntity.mjs +1 -1
- package/dist/cache/entities/CacheRecord.mjs +1 -1
- package/dist/cache/persistence/TokenCacheContext.mjs +1 -1
- package/dist/cache/utils/CacheHelpers.mjs +1 -1
- package/dist/client/AuthorizationCodeClient.mjs +1 -1
- package/dist/client/BaseClient.mjs +1 -1
- package/dist/client/RefreshTokenClient.mjs +1 -1
- package/dist/client/SilentFlowClient.d.ts.map +1 -1
- package/dist/client/SilentFlowClient.mjs +8 -3
- package/dist/client/SilentFlowClient.mjs.map +1 -1
- package/dist/config/ClientConfiguration.mjs +1 -1
- package/dist/constants/AADServerParamKeys.mjs +1 -1
- package/dist/crypto/ICrypto.mjs +1 -1
- package/dist/crypto/JoseHeader.mjs +1 -1
- package/dist/crypto/PopTokenGenerator.mjs +1 -1
- package/dist/error/AuthError.mjs +1 -1
- package/dist/error/AuthErrorCodes.mjs +1 -1
- package/dist/error/ClientAuthError.mjs +1 -1
- package/dist/error/ClientAuthErrorCodes.mjs +1 -1
- package/dist/error/ClientConfigurationError.mjs +1 -1
- package/dist/error/ClientConfigurationErrorCodes.mjs +1 -1
- package/dist/error/InteractionRequiredAuthError.mjs +1 -1
- package/dist/error/InteractionRequiredAuthErrorCodes.mjs +1 -1
- package/dist/error/JoseHeaderError.mjs +1 -1
- package/dist/error/JoseHeaderErrorCodes.mjs +1 -1
- package/dist/error/ServerError.mjs +1 -1
- package/dist/index.cjs +406 -28
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/logger/Logger.mjs +1 -1
- package/dist/network/INetworkModule.mjs +1 -1
- package/dist/network/NetworkManager.mjs +1 -1
- package/dist/network/ThrottlingUtils.mjs +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.mjs +2 -2
- package/dist/request/AuthenticationHeaderParser.mjs +1 -1
- package/dist/request/RequestParameterBuilder.mjs +1 -1
- package/dist/request/RequestValidator.mjs +1 -1
- package/dist/request/ScopeSet.mjs +1 -1
- package/dist/response/ResponseHandler.mjs +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +55 -5
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.mjs +183 -13
- package/dist/telemetry/performance/PerformanceClient.mjs.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +14 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.mjs +215 -2
- package/dist/telemetry/performance/PerformanceEvent.mjs.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.mjs +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.mjs +1 -1
- package/dist/url/UrlString.mjs +1 -1
- package/dist/utils/Constants.mjs +1 -1
- package/dist/utils/FunctionWrappers.d.ts.map +1 -1
- package/dist/utils/FunctionWrappers.mjs +3 -3
- package/dist/utils/FunctionWrappers.mjs.map +1 -1
- package/dist/utils/ProtocolUtils.mjs +1 -1
- package/dist/utils/StringUtils.mjs +1 -1
- package/dist/utils/TimeUtils.mjs +1 -1
- package/dist/utils/UrlUtils.mjs +1 -1
- package/package.json +1 -1
- package/src/cache/CacheManager.ts +8 -26
- package/src/client/SilentFlowClient.ts +7 -4
- package/src/packageMetadata.ts +1 -1
- package/src/telemetry/performance/IPerformanceClient.ts +4 -1
- package/src/telemetry/performance/PerformanceClient.ts +279 -16
- package/src/telemetry/performance/PerformanceEvent.ts +237 -0
- package/src/utils/FunctionWrappers.ts +12 -6
|
@@ -14,17 +14,227 @@ import {
|
|
|
14
14
|
import {
|
|
15
15
|
IntFields,
|
|
16
16
|
PerformanceEvent,
|
|
17
|
+
PerformanceEventAbbreviations,
|
|
18
|
+
PerformanceEventContext,
|
|
17
19
|
PerformanceEvents,
|
|
20
|
+
PerformanceEventStackedContext,
|
|
18
21
|
PerformanceEventStatus,
|
|
19
22
|
} from "./PerformanceEvent";
|
|
20
23
|
import { IPerformanceMeasurement } from "./IPerformanceMeasurement";
|
|
21
24
|
import { StubPerformanceMeasurement } from "./StubPerformanceClient";
|
|
25
|
+
import { AuthError } from "../../error/AuthError";
|
|
22
26
|
|
|
23
27
|
export interface PreQueueEvent {
|
|
24
28
|
name: PerformanceEvents;
|
|
25
29
|
time: number;
|
|
26
30
|
}
|
|
27
31
|
|
|
32
|
+
/**
|
|
33
|
+
* Starts context by adding payload to the stack
|
|
34
|
+
* @param event {PerformanceEvent}
|
|
35
|
+
* @param abbreviations {Map<string, string>} event name abbreviations
|
|
36
|
+
* @param stack {?PerformanceEventStackedContext[]} stack
|
|
37
|
+
*/
|
|
38
|
+
export function startContext(
|
|
39
|
+
event: PerformanceEvent,
|
|
40
|
+
abbreviations: Map<string, string>,
|
|
41
|
+
stack?: PerformanceEventStackedContext[]
|
|
42
|
+
): void {
|
|
43
|
+
if (!stack) {
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
stack.push({
|
|
48
|
+
name: abbreviations.get(event.name) || event.name,
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Ends context by removing payload from the stack and returning parent or self, if stack is empty, payload
|
|
54
|
+
*
|
|
55
|
+
* @param event {PerformanceEvent}
|
|
56
|
+
* @param abbreviations {Map<string, string>} event name abbreviations
|
|
57
|
+
* @param stack {?PerformanceEventStackedContext[]} stack
|
|
58
|
+
* @param error {?unknown} error
|
|
59
|
+
*/
|
|
60
|
+
export function endContext(
|
|
61
|
+
event: PerformanceEvent,
|
|
62
|
+
abbreviations: Map<string, string>,
|
|
63
|
+
stack?: PerformanceEventStackedContext[],
|
|
64
|
+
error?: unknown
|
|
65
|
+
): PerformanceEventContext | undefined {
|
|
66
|
+
if (!stack?.length) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const peek = (stack: PerformanceEventStackedContext[]) => {
|
|
71
|
+
return stack.length ? stack[stack.length - 1] : undefined;
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
const abbrEventName = abbreviations.get(event.name) || event.name;
|
|
75
|
+
const top = peek(stack);
|
|
76
|
+
if (top?.name !== abbrEventName) {
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const current = stack?.pop();
|
|
81
|
+
if (!current) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const errorCode =
|
|
86
|
+
error instanceof AuthError
|
|
87
|
+
? error.errorCode
|
|
88
|
+
: error instanceof Error
|
|
89
|
+
? error.name
|
|
90
|
+
: undefined;
|
|
91
|
+
const subErr = error instanceof AuthError ? error.subError : undefined;
|
|
92
|
+
|
|
93
|
+
if (errorCode && current.childErr !== errorCode) {
|
|
94
|
+
current.err = errorCode;
|
|
95
|
+
if (subErr) {
|
|
96
|
+
current.subErr = subErr;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
delete current.name;
|
|
101
|
+
delete current.childErr;
|
|
102
|
+
|
|
103
|
+
const context: PerformanceEventContext = {
|
|
104
|
+
...current,
|
|
105
|
+
dur: event.durationMs,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
if (!event.success) {
|
|
109
|
+
context.fail = 1;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const parent = peek(stack);
|
|
113
|
+
if (!parent) {
|
|
114
|
+
return { [abbrEventName]: context };
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (errorCode) {
|
|
118
|
+
parent.childErr = errorCode;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
let childName: string;
|
|
122
|
+
if (!parent[abbrEventName]) {
|
|
123
|
+
childName = abbrEventName;
|
|
124
|
+
} else {
|
|
125
|
+
const siblings = Object.keys(parent).filter((key) =>
|
|
126
|
+
key.startsWith(abbrEventName)
|
|
127
|
+
).length;
|
|
128
|
+
childName = `${abbrEventName}_${siblings + 1}`;
|
|
129
|
+
}
|
|
130
|
+
parent[childName] = context;
|
|
131
|
+
return parent;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Adds error name and stack trace to the telemetry event
|
|
136
|
+
* @param error {Error}
|
|
137
|
+
* @param logger {Logger}
|
|
138
|
+
* @param event {PerformanceEvent}
|
|
139
|
+
* @param stackMaxSize {number} max error stack size to capture
|
|
140
|
+
*/
|
|
141
|
+
export function addError(
|
|
142
|
+
error: unknown,
|
|
143
|
+
logger: Logger,
|
|
144
|
+
event: PerformanceEvent,
|
|
145
|
+
stackMaxSize: number = 5
|
|
146
|
+
): void {
|
|
147
|
+
if (!(error instanceof Error)) {
|
|
148
|
+
logger.trace(
|
|
149
|
+
"PerformanceClient.addErrorStack: Input error is not instance of Error",
|
|
150
|
+
event.correlationId
|
|
151
|
+
);
|
|
152
|
+
return;
|
|
153
|
+
} else if (error instanceof AuthError) {
|
|
154
|
+
event.errorCode = error.errorCode;
|
|
155
|
+
event.subErrorCode = error.subError;
|
|
156
|
+
return;
|
|
157
|
+
} else if (event.errorStack?.length) {
|
|
158
|
+
logger.trace(
|
|
159
|
+
"PerformanceClient.addErrorStack: Stack already exist",
|
|
160
|
+
event.correlationId
|
|
161
|
+
);
|
|
162
|
+
return;
|
|
163
|
+
} else if (!error.stack?.length) {
|
|
164
|
+
logger.trace(
|
|
165
|
+
"PerformanceClient.addErrorStack: Input stack is empty",
|
|
166
|
+
event.correlationId
|
|
167
|
+
);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
if (error.stack) {
|
|
172
|
+
event.errorStack = compactStack(error.stack, stackMaxSize);
|
|
173
|
+
}
|
|
174
|
+
event.errorName = error.name;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Compacts error stack into array by fetching N first entries
|
|
179
|
+
* @param stack {string} error stack
|
|
180
|
+
* @param stackMaxSize {number} max error stack size to capture
|
|
181
|
+
* @returns {string[]}
|
|
182
|
+
*/
|
|
183
|
+
export function compactStack(stack: string, stackMaxSize: number): string[] {
|
|
184
|
+
if (stackMaxSize < 0) {
|
|
185
|
+
return [];
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
const stackArr = stack.split("\n") || [];
|
|
189
|
+
if (stackArr.length < 2) {
|
|
190
|
+
return [];
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const res = [];
|
|
194
|
+
// Get top N stack lines
|
|
195
|
+
for (
|
|
196
|
+
// Skip first line as it may contain PII data
|
|
197
|
+
let ix = Math.max(stackArr.length - stackMaxSize - 1, 1);
|
|
198
|
+
ix < stackArr.length;
|
|
199
|
+
ix++
|
|
200
|
+
) {
|
|
201
|
+
const line = stackArr[ix];
|
|
202
|
+
if (res.length >= stackMaxSize) {
|
|
203
|
+
break;
|
|
204
|
+
}
|
|
205
|
+
res.push(compactStackLine(line));
|
|
206
|
+
}
|
|
207
|
+
return res;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* Compacts error stack line by shortening file path
|
|
212
|
+
* Example: https://localhost/msal-common/src/authority/Authority.js:100:1 -> Authority.js:100:1
|
|
213
|
+
* @param line {string} stack line
|
|
214
|
+
* @returns {string}
|
|
215
|
+
*/
|
|
216
|
+
export function compactStackLine(line: string): string {
|
|
217
|
+
const filePathIx = line.lastIndexOf(" ") + 1;
|
|
218
|
+
if (filePathIx < 1) {
|
|
219
|
+
return line;
|
|
220
|
+
}
|
|
221
|
+
const filePath = line.substring(filePathIx);
|
|
222
|
+
|
|
223
|
+
let fileNameIx = filePath.lastIndexOf("/");
|
|
224
|
+
fileNameIx = fileNameIx < 0 ? filePath.lastIndexOf("\\") : fileNameIx;
|
|
225
|
+
|
|
226
|
+
if (fileNameIx >= 0) {
|
|
227
|
+
return (
|
|
228
|
+
line.substring(0, filePathIx) +
|
|
229
|
+
"(" +
|
|
230
|
+
filePath.substring(fileNameIx + 1) +
|
|
231
|
+
(filePath.charAt(filePath.length - 1) === ")" ? "" : ")")
|
|
232
|
+
).trimStart();
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
return line.trimStart();
|
|
236
|
+
}
|
|
237
|
+
|
|
28
238
|
export abstract class PerformanceClient implements IPerformanceClient {
|
|
29
239
|
protected authority: string;
|
|
30
240
|
protected libraryName: string;
|
|
@@ -59,6 +269,20 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
59
269
|
|
|
60
270
|
protected intFields: Set<string>;
|
|
61
271
|
|
|
272
|
+
/**
|
|
273
|
+
* Map of stacked events by correlation id.
|
|
274
|
+
*
|
|
275
|
+
* @protected
|
|
276
|
+
*/
|
|
277
|
+
protected eventStack: Map<string, PerformanceEventStackedContext[]>;
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* Event name abbreviations
|
|
281
|
+
*
|
|
282
|
+
* @protected
|
|
283
|
+
*/
|
|
284
|
+
protected abbreviations: Map<string, string>;
|
|
285
|
+
|
|
62
286
|
/**
|
|
63
287
|
* Creates an instance of PerformanceClient,
|
|
64
288
|
* an abstract class containing core performance telemetry logic.
|
|
@@ -71,6 +295,7 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
71
295
|
* @param {string} libraryVersion Version of the library
|
|
72
296
|
* @param {ApplicationTelemetry} applicationTelemetry application name and version
|
|
73
297
|
* @param {Set<String>} intFields integer fields to be truncated
|
|
298
|
+
* @param {Map<string, string>} abbreviations event name abbreviations
|
|
74
299
|
*/
|
|
75
300
|
constructor(
|
|
76
301
|
clientId: string,
|
|
@@ -79,7 +304,8 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
79
304
|
libraryName: string,
|
|
80
305
|
libraryVersion: string,
|
|
81
306
|
applicationTelemetry: ApplicationTelemetry,
|
|
82
|
-
intFields?: Set<string
|
|
307
|
+
intFields?: Set<string>,
|
|
308
|
+
abbreviations?: Map<string, string>
|
|
83
309
|
) {
|
|
84
310
|
this.authority = authority;
|
|
85
311
|
this.libraryName = libraryName;
|
|
@@ -89,12 +315,17 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
89
315
|
this.logger = logger;
|
|
90
316
|
this.callbacks = new Map();
|
|
91
317
|
this.eventsByCorrelationId = new Map();
|
|
318
|
+
this.eventStack = new Map();
|
|
92
319
|
this.queueMeasurements = new Map();
|
|
93
320
|
this.preQueueTimeByCorrelationId = new Map();
|
|
94
321
|
this.intFields = intFields || new Set();
|
|
95
322
|
for (const item of IntFields) {
|
|
96
323
|
this.intFields.add(item);
|
|
97
324
|
}
|
|
325
|
+
this.abbreviations = abbreviations || new Map();
|
|
326
|
+
for (const [key, value] of PerformanceEventAbbreviations) {
|
|
327
|
+
this.abbreviations.set(key, value);
|
|
328
|
+
}
|
|
98
329
|
}
|
|
99
330
|
|
|
100
331
|
/**
|
|
@@ -292,18 +523,27 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
292
523
|
|
|
293
524
|
// Store in progress events so they can be discarded if not ended properly
|
|
294
525
|
this.cacheEventByCorrelationId(inProgressEvent);
|
|
526
|
+
startContext(
|
|
527
|
+
inProgressEvent,
|
|
528
|
+
this.abbreviations,
|
|
529
|
+
this.eventStack.get(eventCorrelationId)
|
|
530
|
+
);
|
|
295
531
|
|
|
296
532
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
297
533
|
return {
|
|
298
534
|
end: (
|
|
299
|
-
event?: Partial<PerformanceEvent
|
|
535
|
+
event?: Partial<PerformanceEvent>,
|
|
536
|
+
error?: unknown
|
|
300
537
|
): PerformanceEvent | null => {
|
|
301
|
-
return this.endMeasurement(
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
538
|
+
return this.endMeasurement(
|
|
539
|
+
{
|
|
540
|
+
// Initial set of event properties
|
|
541
|
+
...inProgressEvent,
|
|
542
|
+
// Properties set when event ends
|
|
543
|
+
...event,
|
|
544
|
+
},
|
|
545
|
+
error
|
|
546
|
+
);
|
|
307
547
|
},
|
|
308
548
|
discard: () => {
|
|
309
549
|
return this.discardMeasurements(inProgressEvent.correlationId);
|
|
@@ -329,10 +569,13 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
329
569
|
* otherwise.
|
|
330
570
|
*
|
|
331
571
|
* @param {PerformanceEvent} event
|
|
332
|
-
* @param {
|
|
572
|
+
* @param {unknown} error
|
|
333
573
|
* @returns {(PerformanceEvent | null)}
|
|
334
574
|
*/
|
|
335
|
-
endMeasurement(
|
|
575
|
+
endMeasurement(
|
|
576
|
+
event: PerformanceEvent,
|
|
577
|
+
error?: unknown
|
|
578
|
+
): PerformanceEvent | null {
|
|
336
579
|
const rootEvent: PerformanceEvent | undefined =
|
|
337
580
|
this.eventsByCorrelationId.get(event.correlationId);
|
|
338
581
|
if (!rootEvent) {
|
|
@@ -349,6 +592,18 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
349
592
|
totalQueueCount: 0,
|
|
350
593
|
manuallyCompletedCount: 0,
|
|
351
594
|
};
|
|
595
|
+
|
|
596
|
+
event.durationMs = Math.round(
|
|
597
|
+
event.durationMs || this.getDurationMs(event.startTimeMs)
|
|
598
|
+
);
|
|
599
|
+
|
|
600
|
+
const context = endContext(
|
|
601
|
+
event,
|
|
602
|
+
this.abbreviations,
|
|
603
|
+
this.eventStack.get(rootEvent.correlationId),
|
|
604
|
+
error
|
|
605
|
+
);
|
|
606
|
+
|
|
352
607
|
if (isRoot) {
|
|
353
608
|
queueInfo = this.getQueueInfo(event.correlationId);
|
|
354
609
|
this.discardCache(rootEvent.correlationId);
|
|
@@ -356,19 +611,21 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
356
611
|
rootEvent.incompleteSubMeasurements?.delete(event.eventId);
|
|
357
612
|
}
|
|
358
613
|
|
|
359
|
-
const durationMs =
|
|
360
|
-
event.durationMs || this.getDurationMs(event.startTimeMs);
|
|
361
614
|
this.logger.trace(
|
|
362
|
-
`PerformanceClient: Performance measurement ended for ${event.name}: ${durationMs} ms`,
|
|
615
|
+
`PerformanceClient: Performance measurement ended for ${event.name}: ${event.durationMs} ms`,
|
|
363
616
|
event.correlationId
|
|
364
617
|
);
|
|
365
618
|
|
|
366
619
|
// Add sub-measurement attribute to root event.
|
|
367
620
|
if (!isRoot) {
|
|
368
|
-
rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
|
|
621
|
+
rootEvent[event.name + "DurationMs"] = Math.floor(event.durationMs);
|
|
369
622
|
return { ...rootEvent };
|
|
370
623
|
}
|
|
371
624
|
|
|
625
|
+
if (error) {
|
|
626
|
+
addError(error, this.logger, rootEvent);
|
|
627
|
+
}
|
|
628
|
+
|
|
372
629
|
let finalEvent: PerformanceEvent = { ...rootEvent, ...event };
|
|
373
630
|
let incompleteSubsCount: number = 0;
|
|
374
631
|
// Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
|
|
@@ -383,12 +640,12 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
383
640
|
|
|
384
641
|
finalEvent = {
|
|
385
642
|
...finalEvent,
|
|
386
|
-
durationMs: Math.round(durationMs),
|
|
387
643
|
queuedTimeMs: queueInfo.totalQueueTime,
|
|
388
644
|
queuedCount: queueInfo.totalQueueCount,
|
|
389
645
|
queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount,
|
|
390
646
|
status: PerformanceEventStatus.Completed,
|
|
391
647
|
incompleteSubsCount,
|
|
648
|
+
context,
|
|
392
649
|
};
|
|
393
650
|
this.truncateIntegralFields(finalEvent);
|
|
394
651
|
this.emitEvents([finalEvent], event.correlationId);
|
|
@@ -476,6 +733,7 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
476
733
|
event.correlationId
|
|
477
734
|
);
|
|
478
735
|
this.eventsByCorrelationId.set(event.correlationId, { ...event });
|
|
736
|
+
this.eventStack.set(event.correlationId, []);
|
|
479
737
|
}
|
|
480
738
|
}
|
|
481
739
|
|
|
@@ -540,6 +798,12 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
540
798
|
correlationId
|
|
541
799
|
);
|
|
542
800
|
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
801
|
+
|
|
802
|
+
this.logger.trace(
|
|
803
|
+
"PerformanceClient: Event stack discarded",
|
|
804
|
+
correlationId
|
|
805
|
+
);
|
|
806
|
+
this.eventStack.delete(correlationId);
|
|
543
807
|
}
|
|
544
808
|
|
|
545
809
|
/**
|
|
@@ -606,7 +870,6 @@ export abstract class PerformanceClient implements IPerformanceClient {
|
|
|
606
870
|
/**
|
|
607
871
|
* Enforce truncation of integral fields in performance event.
|
|
608
872
|
* @param {PerformanceEvent} event performance event to update.
|
|
609
|
-
* @param {Set<string>} intFields integral fields.
|
|
610
873
|
*/
|
|
611
874
|
private truncateIntegralFields(event: PerformanceEvent): void {
|
|
612
875
|
this.intFields.forEach((key) => {
|
|
@@ -300,6 +300,225 @@ export const PerformanceEvents = {
|
|
|
300
300
|
export type PerformanceEvents =
|
|
301
301
|
(typeof PerformanceEvents)[keyof typeof PerformanceEvents];
|
|
302
302
|
|
|
303
|
+
export const PerformanceEventAbbreviations: ReadonlyMap<string, string> =
|
|
304
|
+
new Map([
|
|
305
|
+
[PerformanceEvents.AcquireTokenByCode, "ATByCode"],
|
|
306
|
+
[PerformanceEvents.AcquireTokenByRefreshToken, "ATByRT"],
|
|
307
|
+
[PerformanceEvents.AcquireTokenSilent, "ATS"],
|
|
308
|
+
[PerformanceEvents.AcquireTokenSilentAsync, "ATSAsync"],
|
|
309
|
+
[PerformanceEvents.AcquireTokenPopup, "ATPopup"],
|
|
310
|
+
[PerformanceEvents.AcquireTokenRedirect, "ATRedirect"],
|
|
311
|
+
[
|
|
312
|
+
PerformanceEvents.CryptoOptsGetPublicKeyThumbprint,
|
|
313
|
+
"CryptoGetPKThumb",
|
|
314
|
+
],
|
|
315
|
+
[PerformanceEvents.CryptoOptsSignJwt, "CryptoSignJwt"],
|
|
316
|
+
[PerformanceEvents.SilentCacheClientAcquireToken, "SltCacheClientAT"],
|
|
317
|
+
[PerformanceEvents.SilentIframeClientAcquireToken, "SltIframeClientAT"],
|
|
318
|
+
[PerformanceEvents.SilentRefreshClientAcquireToken, "SltRClientAT"],
|
|
319
|
+
[PerformanceEvents.SsoSilent, "SsoSlt"],
|
|
320
|
+
[
|
|
321
|
+
PerformanceEvents.StandardInteractionClientGetDiscoveredAuthority,
|
|
322
|
+
"StdIntClientGetDiscAuth",
|
|
323
|
+
],
|
|
324
|
+
[
|
|
325
|
+
PerformanceEvents.FetchAccountIdWithNativeBroker,
|
|
326
|
+
"FetchAccIdWithNtvBroker",
|
|
327
|
+
],
|
|
328
|
+
[
|
|
329
|
+
PerformanceEvents.NativeInteractionClientAcquireToken,
|
|
330
|
+
"NtvIntClientAT",
|
|
331
|
+
],
|
|
332
|
+
[
|
|
333
|
+
PerformanceEvents.BaseClientCreateTokenRequestHeaders,
|
|
334
|
+
"BaseClientCreateTReqHead",
|
|
335
|
+
],
|
|
336
|
+
[
|
|
337
|
+
PerformanceEvents.RefreshTokenClientExecutePostToTokenEndpoint,
|
|
338
|
+
"RTClientExecPost",
|
|
339
|
+
],
|
|
340
|
+
[
|
|
341
|
+
PerformanceEvents.AuthorizationCodeClientExecutePostToTokenEndpoint,
|
|
342
|
+
"AuthCodeClientExecPost",
|
|
343
|
+
],
|
|
344
|
+
[PerformanceEvents.BrokerHandhshake, "BrokerHandshake"],
|
|
345
|
+
[
|
|
346
|
+
PerformanceEvents.AcquireTokenByRefreshTokenInBroker,
|
|
347
|
+
"ATByRTInBroker",
|
|
348
|
+
],
|
|
349
|
+
[PerformanceEvents.AcquireTokenByBroker, "ATByBroker"],
|
|
350
|
+
[
|
|
351
|
+
PerformanceEvents.RefreshTokenClientExecuteTokenRequest,
|
|
352
|
+
"RTClientExecTReq",
|
|
353
|
+
],
|
|
354
|
+
[PerformanceEvents.RefreshTokenClientAcquireToken, "RTClientAT"],
|
|
355
|
+
[
|
|
356
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenWithCachedRefreshToken,
|
|
357
|
+
"RTClientATWithCachedRT",
|
|
358
|
+
],
|
|
359
|
+
[
|
|
360
|
+
PerformanceEvents.RefreshTokenClientAcquireTokenByRefreshToken,
|
|
361
|
+
"RTClientATByRT",
|
|
362
|
+
],
|
|
363
|
+
[
|
|
364
|
+
PerformanceEvents.RefreshTokenClientCreateTokenRequestBody,
|
|
365
|
+
"RTClientCreateTReqBody",
|
|
366
|
+
],
|
|
367
|
+
[PerformanceEvents.AcquireTokenFromCache, "ATFromCache"],
|
|
368
|
+
[
|
|
369
|
+
PerformanceEvents.SilentFlowClientAcquireCachedToken,
|
|
370
|
+
"SltFlowClientATCached",
|
|
371
|
+
],
|
|
372
|
+
[
|
|
373
|
+
PerformanceEvents.SilentFlowClientGenerateResultFromCacheRecord,
|
|
374
|
+
"SltFlowClientGenResFromCache",
|
|
375
|
+
],
|
|
376
|
+
[PerformanceEvents.AcquireTokenBySilentIframe, "ATBySltIframe"],
|
|
377
|
+
[PerformanceEvents.InitializeBaseRequest, "InitBaseReq"],
|
|
378
|
+
[PerformanceEvents.InitializeSilentRequest, "InitSltReq"],
|
|
379
|
+
[
|
|
380
|
+
PerformanceEvents.InitializeClientApplication,
|
|
381
|
+
"InitClientApplication",
|
|
382
|
+
],
|
|
383
|
+
[PerformanceEvents.SilentIframeClientTokenHelper, "SIClientTHelper"],
|
|
384
|
+
[
|
|
385
|
+
PerformanceEvents.SilentHandlerInitiateAuthRequest,
|
|
386
|
+
"SHandlerInitAuthReq",
|
|
387
|
+
],
|
|
388
|
+
[
|
|
389
|
+
PerformanceEvents.SilentHandlerMonitorIframeForHash,
|
|
390
|
+
"SltHandlerMonitorIframeForHash",
|
|
391
|
+
],
|
|
392
|
+
[PerformanceEvents.SilentHandlerLoadFrame, "SHandlerLoadFrame"],
|
|
393
|
+
[PerformanceEvents.SilentHandlerLoadFrameSync, "SHandlerLoadFrameSync"],
|
|
394
|
+
|
|
395
|
+
[
|
|
396
|
+
PerformanceEvents.StandardInteractionClientCreateAuthCodeClient,
|
|
397
|
+
"StdIntClientCreateAuthCodeClient",
|
|
398
|
+
],
|
|
399
|
+
[
|
|
400
|
+
PerformanceEvents.StandardInteractionClientGetClientConfiguration,
|
|
401
|
+
"StdIntClientGetClientConf",
|
|
402
|
+
],
|
|
403
|
+
[
|
|
404
|
+
PerformanceEvents.StandardInteractionClientInitializeAuthorizationRequest,
|
|
405
|
+
"StdIntClientInitAuthReq",
|
|
406
|
+
],
|
|
407
|
+
[
|
|
408
|
+
PerformanceEvents.StandardInteractionClientInitializeAuthorizationCodeRequest,
|
|
409
|
+
"StdIntClientInitAuthCodeReq",
|
|
410
|
+
],
|
|
411
|
+
|
|
412
|
+
[PerformanceEvents.GetAuthCodeUrl, "GetAuthCodeUrl"],
|
|
413
|
+
|
|
414
|
+
[
|
|
415
|
+
PerformanceEvents.HandleCodeResponseFromServer,
|
|
416
|
+
"HandleCodeResFromServer",
|
|
417
|
+
],
|
|
418
|
+
[PerformanceEvents.HandleCodeResponse, "HandleCodeResp"],
|
|
419
|
+
[PerformanceEvents.UpdateTokenEndpointAuthority, "UpdTEndpointAuth"],
|
|
420
|
+
|
|
421
|
+
[PerformanceEvents.AuthClientAcquireToken, "AuthClientAT"],
|
|
422
|
+
[PerformanceEvents.AuthClientExecuteTokenRequest, "AuthClientExecTReq"],
|
|
423
|
+
[
|
|
424
|
+
PerformanceEvents.AuthClientCreateTokenRequestBody,
|
|
425
|
+
"AuthClientCreateTReqBody",
|
|
426
|
+
],
|
|
427
|
+
[
|
|
428
|
+
PerformanceEvents.AuthClientCreateQueryString,
|
|
429
|
+
"AuthClientCreateQueryStr",
|
|
430
|
+
],
|
|
431
|
+
[PerformanceEvents.PopTokenGenerateCnf, "PopTGenCnf"],
|
|
432
|
+
[PerformanceEvents.PopTokenGenerateKid, "PopTGenKid"],
|
|
433
|
+
[PerformanceEvents.HandleServerTokenResponse, "HandleServerTRes"],
|
|
434
|
+
[PerformanceEvents.DeserializeResponse, "DeserializeRes"],
|
|
435
|
+
[
|
|
436
|
+
PerformanceEvents.AuthorityFactoryCreateDiscoveredInstance,
|
|
437
|
+
"AuthFactCreateDiscInst",
|
|
438
|
+
],
|
|
439
|
+
[
|
|
440
|
+
PerformanceEvents.AuthorityResolveEndpointsAsync,
|
|
441
|
+
"AuthResolveEndpointsAsync",
|
|
442
|
+
],
|
|
443
|
+
[
|
|
444
|
+
PerformanceEvents.AuthorityResolveEndpointsFromLocalSources,
|
|
445
|
+
"AuthResolveEndpointsFromLocal",
|
|
446
|
+
],
|
|
447
|
+
[
|
|
448
|
+
PerformanceEvents.AuthorityGetCloudDiscoveryMetadataFromNetwork,
|
|
449
|
+
"AuthGetCDMetaFromNet",
|
|
450
|
+
],
|
|
451
|
+
[
|
|
452
|
+
PerformanceEvents.AuthorityUpdateCloudDiscoveryMetadata,
|
|
453
|
+
"AuthUpdCDMeta",
|
|
454
|
+
],
|
|
455
|
+
[
|
|
456
|
+
PerformanceEvents.AuthorityGetEndpointMetadataFromNetwork,
|
|
457
|
+
"AuthUpdCDMetaFromNet",
|
|
458
|
+
],
|
|
459
|
+
[
|
|
460
|
+
PerformanceEvents.AuthorityUpdateEndpointMetadata,
|
|
461
|
+
"AuthUpdEndpointMeta",
|
|
462
|
+
],
|
|
463
|
+
[
|
|
464
|
+
PerformanceEvents.AuthorityUpdateMetadataWithRegionalInformation,
|
|
465
|
+
"AuthUpdMetaWithRegInfo",
|
|
466
|
+
],
|
|
467
|
+
[PerformanceEvents.RegionDiscoveryDetectRegion, "RegDiscDetectReg"],
|
|
468
|
+
[
|
|
469
|
+
PerformanceEvents.RegionDiscoveryGetRegionFromIMDS,
|
|
470
|
+
"RegDiscGetRegFromIMDS",
|
|
471
|
+
],
|
|
472
|
+
[
|
|
473
|
+
PerformanceEvents.RegionDiscoveryGetCurrentVersion,
|
|
474
|
+
"RegDiscGetCurrentVer",
|
|
475
|
+
],
|
|
476
|
+
[PerformanceEvents.AcquireTokenByCodeAsync, "ATByCodeAsync"],
|
|
477
|
+
[
|
|
478
|
+
PerformanceEvents.GetEndpointMetadataFromNetwork,
|
|
479
|
+
"GetEndpointMetaFromNet",
|
|
480
|
+
],
|
|
481
|
+
[
|
|
482
|
+
PerformanceEvents.GetCloudDiscoveryMetadataFromNetworkMeasurement,
|
|
483
|
+
"GetCDMetaFromNet",
|
|
484
|
+
],
|
|
485
|
+
[
|
|
486
|
+
PerformanceEvents.HandleRedirectPromiseMeasurement,
|
|
487
|
+
"HandleRedirectPromise",
|
|
488
|
+
],
|
|
489
|
+
[
|
|
490
|
+
PerformanceEvents.HandleNativeRedirectPromiseMeasurement,
|
|
491
|
+
"HandleNtvRedirectPromise",
|
|
492
|
+
],
|
|
493
|
+
[
|
|
494
|
+
PerformanceEvents.UpdateCloudDiscoveryMetadataMeasurement,
|
|
495
|
+
"UpdateCDMeta",
|
|
496
|
+
],
|
|
497
|
+
[
|
|
498
|
+
PerformanceEvents.UsernamePasswordClientAcquireToken,
|
|
499
|
+
"UserPassClientAT",
|
|
500
|
+
],
|
|
501
|
+
[
|
|
502
|
+
PerformanceEvents.NativeMessageHandlerHandshake,
|
|
503
|
+
"NtvMsgHandlerHandshake",
|
|
504
|
+
],
|
|
505
|
+
[PerformanceEvents.NativeGenerateAuthResult, "NtvGenAuthRes"],
|
|
506
|
+
[PerformanceEvents.RemoveHiddenIframe, "RemoveHiddenIframe"],
|
|
507
|
+
[
|
|
508
|
+
PerformanceEvents.ClearTokensAndKeysWithClaims,
|
|
509
|
+
"ClearTAndKeysWithClaims",
|
|
510
|
+
],
|
|
511
|
+
[PerformanceEvents.CacheManagerGetRefreshToken, "CacheManagerGetRT"],
|
|
512
|
+
[PerformanceEvents.GeneratePkceCodes, "GenPkceCodes"],
|
|
513
|
+
[PerformanceEvents.GenerateCodeVerifier, "GenCodeVerifier"],
|
|
514
|
+
[
|
|
515
|
+
PerformanceEvents.GenerateCodeChallengeFromVerifier,
|
|
516
|
+
"GenCodeChallengeFromVerifier",
|
|
517
|
+
],
|
|
518
|
+
[PerformanceEvents.Sha256Digest, "Sha256Digest"],
|
|
519
|
+
[PerformanceEvents.GetRandomValues, "GetRandomValues"],
|
|
520
|
+
]);
|
|
521
|
+
|
|
303
522
|
/**
|
|
304
523
|
* State of the performance event.
|
|
305
524
|
*
|
|
@@ -573,6 +792,24 @@ export type PerformanceEvent = {
|
|
|
573
792
|
multiMatchedAT?: number;
|
|
574
793
|
multiMatchedID?: number;
|
|
575
794
|
multiMatchedRT?: number;
|
|
795
|
+
|
|
796
|
+
errorName?: string;
|
|
797
|
+
errorStack?: string[];
|
|
798
|
+
|
|
799
|
+
//
|
|
800
|
+
context?: object;
|
|
801
|
+
};
|
|
802
|
+
|
|
803
|
+
export type PerformanceEventContext = {
|
|
804
|
+
dur?: number;
|
|
805
|
+
err?: string;
|
|
806
|
+
subErr?: string;
|
|
807
|
+
fail?: number;
|
|
808
|
+
};
|
|
809
|
+
|
|
810
|
+
export type PerformanceEventStackedContext = PerformanceEventContext & {
|
|
811
|
+
name?: string;
|
|
812
|
+
childErr?: string;
|
|
576
813
|
};
|
|
577
814
|
|
|
578
815
|
export const IntFields: ReadonlySet<string> = new Set([
|
|
@@ -53,9 +53,12 @@ export const invoke = <T extends Array<any>, U>(
|
|
|
53
53
|
} catch (e) {
|
|
54
54
|
logger.trace("Unable to print error message.");
|
|
55
55
|
}
|
|
56
|
-
inProgressEvent?.end(
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
inProgressEvent?.end(
|
|
57
|
+
{
|
|
58
|
+
success: false,
|
|
59
|
+
},
|
|
60
|
+
e
|
|
61
|
+
);
|
|
59
62
|
throw e;
|
|
60
63
|
}
|
|
61
64
|
};
|
|
@@ -111,9 +114,12 @@ export const invokeAsync = <T extends Array<any>, U>(
|
|
|
111
114
|
} catch (e) {
|
|
112
115
|
logger.trace("Unable to print error message.");
|
|
113
116
|
}
|
|
114
|
-
inProgressEvent?.end(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
+
inProgressEvent?.end(
|
|
118
|
+
{
|
|
119
|
+
success: false,
|
|
120
|
+
},
|
|
121
|
+
e
|
|
122
|
+
);
|
|
117
123
|
throw e;
|
|
118
124
|
});
|
|
119
125
|
};
|