@azure/msal-common 6.0.0 → 6.3.0-beta.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/LICENSE +21 -21
- package/README.md +62 -62
- package/dist/_virtual/_tslib.js +1 -1
- package/dist/account/AccountInfo.d.ts +6 -1
- package/dist/account/AccountInfo.d.ts.map +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/AuthToken.js.map +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/CcsCredential.js.map +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/account/ClientInfo.js.map +1 -1
- package/dist/account/TokenClaims.d.ts +30 -0
- package/dist/account/TokenClaims.d.ts.map +1 -1
- package/dist/authority/Authority.d.ts +9 -1
- package/dist/authority/Authority.d.ts.map +1 -1
- package/dist/authority/Authority.js +36 -11
- package/dist/authority/Authority.js.map +1 -1
- package/dist/authority/AuthorityFactory.d.ts +2 -2
- package/dist/authority/AuthorityFactory.d.ts.map +1 -1
- package/dist/authority/AuthorityFactory.js +5 -5
- package/dist/authority/AuthorityFactory.js.map +1 -1
- package/dist/authority/AuthorityOptions.d.ts +8 -0
- package/dist/authority/AuthorityOptions.d.ts.map +1 -1
- package/dist/authority/AuthorityOptions.js +24 -0
- package/dist/authority/AuthorityOptions.js.map +1 -0
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/AuthorityType.js.map +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js.map +1 -1
- package/dist/authority/ImdsOptions.d.ts +7 -0
- package/dist/authority/ImdsOptions.d.ts.map +1 -0
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js.map +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/ProtocolMode.js.map +1 -1
- package/dist/authority/RegionDiscovery.d.ts +3 -6
- package/dist/authority/RegionDiscovery.d.ts.map +1 -1
- package/dist/authority/RegionDiscovery.js +19 -11
- package/dist/authority/RegionDiscovery.js.map +1 -1
- package/dist/cache/CacheManager.d.ts +1 -1
- package/dist/cache/CacheManager.js +3 -3
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccessTokenEntity.js.map +1 -1
- package/dist/cache/entities/AccountEntity.d.ts +3 -1
- package/dist/cache/entities/AccountEntity.d.ts.map +1 -1
- package/dist/cache/entities/AccountEntity.js +16 -12
- package/dist/cache/entities/AccountEntity.js.map +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js.map +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js.map +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CacheRecord.js.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +5 -5
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/IdTokenEntity.js.map +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js.map +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js.map +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js.map +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js.map +1 -1
- package/dist/client/AuthorizationCodeClient.d.ts.map +1 -1
- package/dist/client/AuthorizationCodeClient.js +122 -93
- package/dist/client/AuthorizationCodeClient.js.map +1 -1
- package/dist/client/BaseClient.js +2 -2
- package/dist/client/BaseClient.js.map +1 -1
- package/dist/client/ClientCredentialClient.d.ts.map +1 -1
- package/dist/client/ClientCredentialClient.js +4 -3
- package/dist/client/ClientCredentialClient.js.map +1 -1
- package/dist/client/DeviceCodeClient.d.ts.map +1 -1
- package/dist/client/DeviceCodeClient.js +4 -2
- package/dist/client/DeviceCodeClient.js.map +1 -1
- package/dist/client/OnBehalfOfClient.js +3 -2
- package/dist/client/OnBehalfOfClient.js.map +1 -1
- package/dist/client/RefreshTokenClient.js +2 -1
- package/dist/client/RefreshTokenClient.js.map +1 -1
- package/dist/client/SilentFlowClient.js +1 -1
- package/dist/client/SilentFlowClient.js.map +1 -1
- package/dist/client/UsernamePasswordClient.d.ts.map +1 -1
- package/dist/client/UsernamePasswordClient.js +3 -1
- package/dist/client/UsernamePasswordClient.js.map +1 -1
- package/dist/config/ClientConfiguration.d.ts +29 -1
- package/dist/config/ClientConfiguration.d.ts.map +1 -1
- package/dist/config/ClientConfiguration.js +21 -8
- package/dist/config/ClientConfiguration.js.map +1 -1
- package/dist/crypto/ICrypto.d.ts +4 -2
- package/dist/crypto/ICrypto.d.ts.map +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/ICrypto.js.map +1 -1
- package/dist/crypto/IGuidGenerator.d.ts +5 -0
- package/dist/crypto/IGuidGenerator.d.ts.map +1 -0
- package/dist/crypto/PopTokenGenerator.d.ts +30 -0
- package/dist/crypto/PopTokenGenerator.d.ts.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +38 -2
- package/dist/crypto/PopTokenGenerator.js.map +1 -1
- package/dist/error/AuthError.js +3 -3
- package/dist/error/AuthError.js.map +1 -1
- package/dist/error/ClientAuthError.js +1 -1
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.d.ts +11 -0
- package/dist/error/ClientConfigurationError.d.ts.map +1 -1
- package/dist/error/ClientConfigurationError.js +12 -2
- package/dist/error/ClientConfigurationError.js.map +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/InteractionRequiredAuthError.js.map +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/error/ServerError.js.map +1 -1
- package/dist/index.cjs.js +764 -176
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +8 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/logger/Logger.js +13 -13
- package/dist/logger/Logger.js.map +1 -1
- package/dist/network/INetworkModule.d.ts +1 -0
- package/dist/network/INetworkModule.d.ts.map +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/INetworkModule.js.map +1 -1
- package/dist/network/NetworkManager.js +1 -1
- package/dist/network/NetworkManager.js.map +1 -1
- package/dist/network/ThrottlingUtils.js +1 -1
- package/dist/network/ThrottlingUtils.js.map +1 -1
- package/dist/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.d.ts.map +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.js +3 -3
- package/dist/request/AuthenticationHeaderParser.js.map +1 -1
- package/dist/request/BaseAuthRequest.d.ts +8 -5
- package/dist/request/BaseAuthRequest.d.ts.map +1 -1
- package/dist/request/CommonAuthorizationUrlRequest.d.ts +1 -0
- package/dist/request/CommonAuthorizationUrlRequest.d.ts.map +1 -1
- package/dist/request/CommonEndSessionRequest.d.ts +2 -0
- package/dist/request/CommonEndSessionRequest.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.d.ts +18 -1
- package/dist/request/RequestParameterBuilder.d.ts.map +1 -1
- package/dist/request/RequestParameterBuilder.js +37 -3
- package/dist/request/RequestParameterBuilder.js.map +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/RequestValidator.js.map +1 -1
- package/dist/request/ScopeSet.js +4 -4
- package/dist/request/ScopeSet.js.map +1 -1
- package/dist/response/AuthenticationResult.d.ts +1 -0
- package/dist/response/AuthenticationResult.d.ts.map +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +6 -5
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationCodeResponse.d.ts +1 -0
- package/dist/response/ServerAuthorizationCodeResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +22 -0
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts +6 -0
- package/dist/telemetry/performance/IPerformanceMeasurement.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceClient.d.ts +125 -0
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceClient.js +275 -0
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts +203 -0
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -0
- package/dist/telemetry/performance/PerformanceEvent.js +100 -0
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts +13 -0
- package/dist/telemetry/performance/StubPerformanceClient.d.ts.map +1 -0
- package/dist/telemetry/performance/StubPerformanceClient.js +37 -0
- package/dist/telemetry/performance/StubPerformanceClient.js.map +1 -0
- package/dist/telemetry/server/ServerTelemetryManager.js +4 -4
- package/dist/telemetry/server/ServerTelemetryManager.js.map +1 -1
- package/dist/url/UrlString.js +2 -2
- package/dist/url/UrlString.js.map +1 -1
- package/dist/utils/Constants.d.ts +8 -1
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +9 -2
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +3 -3
- package/dist/utils/ProtocolUtils.js.map +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/StringUtils.js.map +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/dist/utils/TimeUtils.js.map +1 -1
- package/package.json +74 -76
- package/CHANGELOG.json +0 -1282
- package/CHANGELOG.md +0 -491
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { ApplicationTelemetry } from "../../config/ClientConfiguration";
|
|
2
|
+
import { Logger } from "../../logger/Logger";
|
|
3
|
+
import { InProgressPerformanceEvent, IPerformanceClient, PerformanceCallbackFunction } from "./IPerformanceClient";
|
|
4
|
+
import { IPerformanceMeasurement } from "./IPerformanceMeasurement";
|
|
5
|
+
import { PerformanceEvent, PerformanceEvents } from "./PerformanceEvent";
|
|
6
|
+
export declare abstract class PerformanceClient implements IPerformanceClient {
|
|
7
|
+
protected authority: string;
|
|
8
|
+
protected libraryName: string;
|
|
9
|
+
protected libraryVersion: string;
|
|
10
|
+
protected applicationTelemetry: ApplicationTelemetry;
|
|
11
|
+
protected clientId: string;
|
|
12
|
+
protected logger: Logger;
|
|
13
|
+
protected callbacks: Map<string, PerformanceCallbackFunction>;
|
|
14
|
+
/**
|
|
15
|
+
* Multiple events with the same correlation id.
|
|
16
|
+
* Double keyed by correlation id and event id.
|
|
17
|
+
* @protected
|
|
18
|
+
* @type {Map<string, Map<string, PerformanceEvent>>}
|
|
19
|
+
*/
|
|
20
|
+
protected eventsByCorrelationId: Map<string, Map<string, PerformanceEvent>>;
|
|
21
|
+
/**
|
|
22
|
+
* Underlying performance measurements for each operation
|
|
23
|
+
*
|
|
24
|
+
* @protected
|
|
25
|
+
* @type {Map<string, IPerformanceMeasurement>}
|
|
26
|
+
*/
|
|
27
|
+
protected measurementsById: Map<string, IPerformanceMeasurement>;
|
|
28
|
+
/**
|
|
29
|
+
* Creates an instance of PerformanceClient,
|
|
30
|
+
* an abstract class containing core performance telemetry logic.
|
|
31
|
+
*
|
|
32
|
+
* @constructor
|
|
33
|
+
* @param {string} clientId Client ID of the application
|
|
34
|
+
* @param {string} authority Authority used by the application
|
|
35
|
+
* @param {Logger} logger Logger used by the application
|
|
36
|
+
* @param {string} libraryName Name of the library
|
|
37
|
+
* @param {string} libraryVersion Version of the library
|
|
38
|
+
*/
|
|
39
|
+
constructor(clientId: string, authority: string, logger: Logger, libraryName: string, libraryVersion: string, applicationTelemetry: ApplicationTelemetry);
|
|
40
|
+
/**
|
|
41
|
+
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
42
|
+
*
|
|
43
|
+
* @abstract
|
|
44
|
+
* @param {string} measureName
|
|
45
|
+
* @param {string} correlationId
|
|
46
|
+
* @returns {IPerformanceMeasurement}
|
|
47
|
+
*/
|
|
48
|
+
abstract startPerformanceMeasuremeant(measureName: string, correlationId: string): IPerformanceMeasurement;
|
|
49
|
+
/**
|
|
50
|
+
* Generates and returns a unique id, typically a guid.
|
|
51
|
+
*
|
|
52
|
+
* @abstract
|
|
53
|
+
* @returns {string}
|
|
54
|
+
*/
|
|
55
|
+
abstract generateId(): string;
|
|
56
|
+
/**
|
|
57
|
+
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
58
|
+
*
|
|
59
|
+
* @param {PerformanceEvents} measureName
|
|
60
|
+
* @param {?string} [correlationId]
|
|
61
|
+
* @returns {InProgressPerformanceEvent}
|
|
62
|
+
*/
|
|
63
|
+
startMeasurement(measureName: PerformanceEvents, correlationId?: string): InProgressPerformanceEvent;
|
|
64
|
+
/**
|
|
65
|
+
* Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
|
|
66
|
+
* as consumers should instead use the function returned by startMeasurement.
|
|
67
|
+
*
|
|
68
|
+
* @param {PerformanceEvent} event
|
|
69
|
+
* @returns {(PerformanceEvent | null)}
|
|
70
|
+
*/
|
|
71
|
+
endMeasurement(event: PerformanceEvent): PerformanceEvent | null;
|
|
72
|
+
/**
|
|
73
|
+
* Upserts event into event cache.
|
|
74
|
+
* First key is the correlation id, second key is the event id.
|
|
75
|
+
* Allows for events to be grouped by correlation id,
|
|
76
|
+
* and to easily allow for properties on them to be updated.
|
|
77
|
+
*
|
|
78
|
+
* @private
|
|
79
|
+
* @param {PerformanceEvent} event
|
|
80
|
+
*/
|
|
81
|
+
private cacheEventByCorrelationId;
|
|
82
|
+
/**
|
|
83
|
+
* Cache measurements by their id.
|
|
84
|
+
*
|
|
85
|
+
* @private
|
|
86
|
+
* @param {PerformanceEvent} event
|
|
87
|
+
* @param {IPerformanceMeasurement} measurement
|
|
88
|
+
*/
|
|
89
|
+
private cacheMeasurement;
|
|
90
|
+
/**
|
|
91
|
+
* Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
|
|
92
|
+
*
|
|
93
|
+
* @param {PerformanceEvents} measureName
|
|
94
|
+
* @param {string} correlationId
|
|
95
|
+
*/
|
|
96
|
+
flushMeasurements(measureName: PerformanceEvents, correlationId: string): void;
|
|
97
|
+
/**
|
|
98
|
+
* Removes measurements for a given correlation id.
|
|
99
|
+
*
|
|
100
|
+
* @param {string} correlationId
|
|
101
|
+
*/
|
|
102
|
+
discardMeasurements(correlationId: string): void;
|
|
103
|
+
/**
|
|
104
|
+
* Registers a callback function to receive performance events.
|
|
105
|
+
*
|
|
106
|
+
* @param {PerformanceCallbackFunction} callback
|
|
107
|
+
* @returns {string}
|
|
108
|
+
*/
|
|
109
|
+
addPerformanceCallback(callback: PerformanceCallbackFunction): string;
|
|
110
|
+
/**
|
|
111
|
+
* Removes a callback registered with addPerformanceCallback.
|
|
112
|
+
*
|
|
113
|
+
* @param {string} callbackId
|
|
114
|
+
* @returns {boolean}
|
|
115
|
+
*/
|
|
116
|
+
removePerformanceCallback(callbackId: string): boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Emits events to all registered callbacks.
|
|
119
|
+
*
|
|
120
|
+
* @param {PerformanceEvent[]} events
|
|
121
|
+
* @param {?string} [correlationId]
|
|
122
|
+
*/
|
|
123
|
+
emitEvents(events: PerformanceEvent[], correlationId: string): void;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=PerformanceClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PerformanceClient.d.ts","sourceRoot":"","sources":["../../../src/telemetry/performance/PerformanceClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBA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OAMG;IACH,gBAAgB,CAAC,WAAW,EAAE,iBAAiB,EAAE,aAAa,CAAC,EAAE,MAAM,GAAG,0BAA0B;IA0DpG;;;;;;OAMG;IACH,cAAc,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,GAAG,IAAI;IA6BhE;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;IAWjC;;;;;;OAMG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;;;OAKG;IACH,iBAAiB,CAAC,WAAW,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;IAwE9E;;;;OAIG;IACH,mBAAmB,CAAC,aAAa,EAAE,MAAM,GAAG,IAAI;IAKhD;;;;;OAKG;IACH,sBAAsB,CAAC,QAAQ,EAAE,2BAA2B,GAAG,MAAM;IAQrE;;;;;OAKG;IACH,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO;IAYtD;;;;;OAKG;IACH,UAAU,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,IAAI;CAQtE"}
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
/*! @azure/msal-common v6.3.0-beta.0 2022-04-27 */
|
|
2
|
+
'use strict';
|
|
3
|
+
import { __assign } from '../../_virtual/_tslib.js';
|
|
4
|
+
import { PerformanceEventStatus } from './PerformanceEvent.js';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
8
|
+
* Licensed under the MIT License.
|
|
9
|
+
*/
|
|
10
|
+
var PerformanceClient = /** @class */ (function () {
|
|
11
|
+
/**
|
|
12
|
+
* Creates an instance of PerformanceClient,
|
|
13
|
+
* an abstract class containing core performance telemetry logic.
|
|
14
|
+
*
|
|
15
|
+
* @constructor
|
|
16
|
+
* @param {string} clientId Client ID of the application
|
|
17
|
+
* @param {string} authority Authority used by the application
|
|
18
|
+
* @param {Logger} logger Logger used by the application
|
|
19
|
+
* @param {string} libraryName Name of the library
|
|
20
|
+
* @param {string} libraryVersion Version of the library
|
|
21
|
+
*/
|
|
22
|
+
function PerformanceClient(clientId, authority, logger, libraryName, libraryVersion, applicationTelemetry) {
|
|
23
|
+
this.authority = authority;
|
|
24
|
+
this.libraryName = libraryName;
|
|
25
|
+
this.libraryVersion = libraryVersion;
|
|
26
|
+
this.applicationTelemetry = applicationTelemetry;
|
|
27
|
+
this.clientId = clientId;
|
|
28
|
+
this.logger = logger;
|
|
29
|
+
this.callbacks = new Map();
|
|
30
|
+
this.eventsByCorrelationId = new Map();
|
|
31
|
+
this.measurementsById = new Map();
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
35
|
+
*
|
|
36
|
+
* @param {PerformanceEvents} measureName
|
|
37
|
+
* @param {?string} [correlationId]
|
|
38
|
+
* @returns {InProgressPerformanceEvent}
|
|
39
|
+
*/
|
|
40
|
+
PerformanceClient.prototype.startMeasurement = function (measureName, correlationId) {
|
|
41
|
+
var _this = this;
|
|
42
|
+
var _a, _b;
|
|
43
|
+
// Generate a placeholder correlation if the request does not provide one
|
|
44
|
+
var eventCorrelationId = correlationId || this.generateId();
|
|
45
|
+
if (!correlationId) {
|
|
46
|
+
this.logger.info("PerformanceClient: No correlation id provided for " + measureName + ", generating", eventCorrelationId);
|
|
47
|
+
}
|
|
48
|
+
this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
|
|
49
|
+
var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
|
|
50
|
+
performanceMeasurement.startMeasurement();
|
|
51
|
+
var inProgressEvent = {
|
|
52
|
+
eventId: this.generateId(),
|
|
53
|
+
status: PerformanceEventStatus.InProgress,
|
|
54
|
+
authority: this.authority,
|
|
55
|
+
libraryName: this.libraryName,
|
|
56
|
+
libraryVersion: this.libraryVersion,
|
|
57
|
+
appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
|
|
58
|
+
appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
|
|
59
|
+
clientId: this.clientId,
|
|
60
|
+
name: measureName,
|
|
61
|
+
startTimeMs: Date.now(),
|
|
62
|
+
correlationId: eventCorrelationId
|
|
63
|
+
};
|
|
64
|
+
// Store in progress events so they can be discarded if not ended properly
|
|
65
|
+
this.cacheEventByCorrelationId(inProgressEvent);
|
|
66
|
+
this.cacheMeasurement(inProgressEvent, performanceMeasurement);
|
|
67
|
+
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
68
|
+
return {
|
|
69
|
+
endMeasurement: function (event) {
|
|
70
|
+
var completedEvent = _this.endMeasurement(__assign(__assign({}, inProgressEvent), event));
|
|
71
|
+
if (completedEvent) {
|
|
72
|
+
// Cache event so that submeasurements can be added downstream
|
|
73
|
+
_this.cacheEventByCorrelationId(completedEvent);
|
|
74
|
+
}
|
|
75
|
+
return completedEvent;
|
|
76
|
+
},
|
|
77
|
+
flushMeasurement: function () {
|
|
78
|
+
return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
|
|
79
|
+
},
|
|
80
|
+
discardMeasurement: function () {
|
|
81
|
+
return _this.discardMeasurements(inProgressEvent.correlationId);
|
|
82
|
+
},
|
|
83
|
+
measurement: performanceMeasurement,
|
|
84
|
+
event: inProgressEvent
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
|
|
89
|
+
* as consumers should instead use the function returned by startMeasurement.
|
|
90
|
+
*
|
|
91
|
+
* @param {PerformanceEvent} event
|
|
92
|
+
* @returns {(PerformanceEvent | null)}
|
|
93
|
+
*/
|
|
94
|
+
PerformanceClient.prototype.endMeasurement = function (event) {
|
|
95
|
+
var performanceMeasurement = this.measurementsById.get(event.eventId);
|
|
96
|
+
if (performanceMeasurement) {
|
|
97
|
+
// Immediately delete so that the same event isnt ended twice
|
|
98
|
+
this.measurementsById.delete(event.eventId);
|
|
99
|
+
performanceMeasurement.endMeasurement();
|
|
100
|
+
var durationMs = performanceMeasurement.flushMeasurement();
|
|
101
|
+
// null indicates no measurement was taken (e.g. needed performance APIs not present)
|
|
102
|
+
if (durationMs !== null) {
|
|
103
|
+
this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
|
|
104
|
+
var completedEvent = __assign(__assign({
|
|
105
|
+
// Allow duration to be overwritten when event ends (e.g. testing), but not status
|
|
106
|
+
durationMs: Math.round(durationMs) }, event), { status: PerformanceEventStatus.Completed });
|
|
107
|
+
return completedEvent;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
this.logger.trace("PerformanceClient: Performance measurement not taken", event.correlationId);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
|
|
115
|
+
}
|
|
116
|
+
return null;
|
|
117
|
+
};
|
|
118
|
+
/**
|
|
119
|
+
* Upserts event into event cache.
|
|
120
|
+
* First key is the correlation id, second key is the event id.
|
|
121
|
+
* Allows for events to be grouped by correlation id,
|
|
122
|
+
* and to easily allow for properties on them to be updated.
|
|
123
|
+
*
|
|
124
|
+
* @private
|
|
125
|
+
* @param {PerformanceEvent} event
|
|
126
|
+
*/
|
|
127
|
+
PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
|
|
128
|
+
var existingEvents = this.eventsByCorrelationId.get(event.correlationId);
|
|
129
|
+
if (existingEvents) {
|
|
130
|
+
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
|
|
131
|
+
existingEvents.set(event.eventId, event);
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
|
|
135
|
+
this.eventsByCorrelationId.set(event.correlationId, new Map().set(event.eventId, event));
|
|
136
|
+
}
|
|
137
|
+
};
|
|
138
|
+
/**
|
|
139
|
+
* Cache measurements by their id.
|
|
140
|
+
*
|
|
141
|
+
* @private
|
|
142
|
+
* @param {PerformanceEvent} event
|
|
143
|
+
* @param {IPerformanceMeasurement} measurement
|
|
144
|
+
*/
|
|
145
|
+
PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
|
|
146
|
+
this.measurementsById.set(event.eventId, measurement);
|
|
147
|
+
};
|
|
148
|
+
/**
|
|
149
|
+
* Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
|
|
150
|
+
*
|
|
151
|
+
* @param {PerformanceEvents} measureName
|
|
152
|
+
* @param {string} correlationId
|
|
153
|
+
*/
|
|
154
|
+
PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
|
|
155
|
+
var _this = this;
|
|
156
|
+
this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
|
|
157
|
+
var eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);
|
|
158
|
+
if (eventsForCorrelationId) {
|
|
159
|
+
this.discardMeasurements(correlationId);
|
|
160
|
+
/*
|
|
161
|
+
* Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
|
|
162
|
+
* Incomplete submeasurements are likely an instrumentation bug that should be fixed.
|
|
163
|
+
* IE only supports Map.forEach.
|
|
164
|
+
*/
|
|
165
|
+
var completedEvents_1 = [];
|
|
166
|
+
eventsForCorrelationId.forEach(function (event) {
|
|
167
|
+
if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
|
|
168
|
+
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
|
|
169
|
+
var completedEvent = _this.endMeasurement(event);
|
|
170
|
+
if (completedEvent) {
|
|
171
|
+
completedEvents_1.push(completedEvent);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
completedEvents_1.push(event);
|
|
175
|
+
});
|
|
176
|
+
// Sort events by start time (earliest first)
|
|
177
|
+
var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
|
|
178
|
+
// Take completed top level event and add completed submeasurements durations as properties
|
|
179
|
+
var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === PerformanceEventStatus.Completed; });
|
|
180
|
+
if (topLevelEvents.length > 0) {
|
|
181
|
+
/*
|
|
182
|
+
* Only take the first top-level event if there are multiple events with the same correlation id.
|
|
183
|
+
* This greatly simplifies logic for submeasurements.
|
|
184
|
+
*/
|
|
185
|
+
if (topLevelEvents.length > 1) {
|
|
186
|
+
this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
|
|
187
|
+
}
|
|
188
|
+
var topLevelEvent = topLevelEvents[0];
|
|
189
|
+
this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
|
|
190
|
+
// Build event object with top level and sub measurements
|
|
191
|
+
var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
|
|
192
|
+
if (current.name !== measureName) {
|
|
193
|
+
_this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
|
|
194
|
+
// TODO: Emit additional properties for each subMeasurement
|
|
195
|
+
var subMeasurementName = current.name + "DurationMs";
|
|
196
|
+
/*
|
|
197
|
+
* Some code paths, such as resolving an authority, can occur multiple times.
|
|
198
|
+
* Only take the first measurement, since the second could be read from the cache,
|
|
199
|
+
* or due to the same correlation id being used for two distinct requests.
|
|
200
|
+
*/
|
|
201
|
+
if (!previous[subMeasurementName]) {
|
|
202
|
+
previous[subMeasurementName] = current.durationMs;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
_this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
return previous;
|
|
209
|
+
}, topLevelEvent);
|
|
210
|
+
this.emitEvents([eventToEmit], eventToEmit.correlationId);
|
|
211
|
+
}
|
|
212
|
+
else {
|
|
213
|
+
this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
this.logger.verbose("PerformanceClient: No measurements found", correlationId);
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Removes measurements for a given correlation id.
|
|
222
|
+
*
|
|
223
|
+
* @param {string} correlationId
|
|
224
|
+
*/
|
|
225
|
+
PerformanceClient.prototype.discardMeasurements = function (correlationId) {
|
|
226
|
+
this.logger.trace("PerformanceClient: Performance measurements discarded", correlationId);
|
|
227
|
+
this.eventsByCorrelationId.delete(correlationId);
|
|
228
|
+
};
|
|
229
|
+
/**
|
|
230
|
+
* Registers a callback function to receive performance events.
|
|
231
|
+
*
|
|
232
|
+
* @param {PerformanceCallbackFunction} callback
|
|
233
|
+
* @returns {string}
|
|
234
|
+
*/
|
|
235
|
+
PerformanceClient.prototype.addPerformanceCallback = function (callback) {
|
|
236
|
+
var callbackId = this.generateId();
|
|
237
|
+
this.callbacks.set(callbackId, callback);
|
|
238
|
+
this.logger.verbose("PerformanceClient: Performance callback registered with id: " + callbackId);
|
|
239
|
+
return callbackId;
|
|
240
|
+
};
|
|
241
|
+
/**
|
|
242
|
+
* Removes a callback registered with addPerformanceCallback.
|
|
243
|
+
*
|
|
244
|
+
* @param {string} callbackId
|
|
245
|
+
* @returns {boolean}
|
|
246
|
+
*/
|
|
247
|
+
PerformanceClient.prototype.removePerformanceCallback = function (callbackId) {
|
|
248
|
+
var result = this.callbacks.delete(callbackId);
|
|
249
|
+
if (result) {
|
|
250
|
+
this.logger.verbose("PerformanceClient: Performance callback " + callbackId + " removed.");
|
|
251
|
+
}
|
|
252
|
+
else {
|
|
253
|
+
this.logger.verbose("PerformanceClient: Performance callback " + callbackId + " not removed.");
|
|
254
|
+
}
|
|
255
|
+
return result;
|
|
256
|
+
};
|
|
257
|
+
/**
|
|
258
|
+
* Emits events to all registered callbacks.
|
|
259
|
+
*
|
|
260
|
+
* @param {PerformanceEvent[]} events
|
|
261
|
+
* @param {?string} [correlationId]
|
|
262
|
+
*/
|
|
263
|
+
PerformanceClient.prototype.emitEvents = function (events, correlationId) {
|
|
264
|
+
var _this = this;
|
|
265
|
+
this.logger.verbose("PerformanceClient: Emitting performance events", correlationId);
|
|
266
|
+
this.callbacks.forEach(function (callback, callbackId) {
|
|
267
|
+
_this.logger.trace("PerformanceClient: Emitting event to callback " + callbackId, correlationId);
|
|
268
|
+
callback.apply(null, [events]);
|
|
269
|
+
});
|
|
270
|
+
};
|
|
271
|
+
return PerformanceClient;
|
|
272
|
+
}());
|
|
273
|
+
|
|
274
|
+
export { PerformanceClient };
|
|
275
|
+
//# sourceMappingURL=PerformanceClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PerformanceClient.js","sources":["../../../src/telemetry/performance/PerformanceClient.ts"],"sourcesContent":["/*\r\n * Copyright (c) Microsoft Corporation. All rights reserved.\r\n * Licensed under the MIT License.\r\n */\r\n\r\nimport { ApplicationTelemetry } from \"../../config/ClientConfiguration\";\r\nimport { Logger } from \"../../logger/Logger\";\r\nimport { InProgressPerformanceEvent, IPerformanceClient, PerformanceCallbackFunction } from \"./IPerformanceClient\";\r\nimport { IPerformanceMeasurement } from \"./IPerformanceMeasurement\";\r\nimport { PerformanceEvent, PerformanceEvents, PerformanceEventStatus } from \"./PerformanceEvent\";\r\n\r\nexport abstract class PerformanceClient implements IPerformanceClient {\r\n protected authority: string;\r\n protected libraryName: string;\r\n protected libraryVersion: string;\r\n protected applicationTelemetry: ApplicationTelemetry;\r\n protected clientId: string;\r\n protected logger: Logger;\r\n protected callbacks: Map<string, PerformanceCallbackFunction>;\r\n \r\n /**\r\n * Multiple events with the same correlation id.\r\n * Double keyed by correlation id and event id.\r\n * @protected\r\n * @type {Map<string, Map<string, PerformanceEvent>>}\r\n */\r\n protected eventsByCorrelationId: Map<string, Map<string, PerformanceEvent>>;\r\n \r\n /**\r\n * Underlying performance measurements for each operation\r\n *\r\n * @protected\r\n * @type {Map<string, IPerformanceMeasurement>}\r\n */\r\n protected measurementsById: Map<string, IPerformanceMeasurement>;\r\n \r\n /**\r\n * Creates an instance of PerformanceClient, \r\n * an abstract class containing core performance telemetry logic.\r\n *\r\n * @constructor\r\n * @param {string} clientId Client ID of the application\r\n * @param {string} authority Authority used by the application\r\n * @param {Logger} logger Logger used by the application\r\n * @param {string} libraryName Name of the library\r\n * @param {string} libraryVersion Version of the library\r\n */\r\n constructor(clientId: string, authority: string, logger: Logger, libraryName: string, libraryVersion: string, applicationTelemetry: ApplicationTelemetry) {\r\n this.authority = authority;\r\n this.libraryName = libraryName;\r\n this.libraryVersion = libraryVersion;\r\n this.applicationTelemetry = applicationTelemetry;\r\n this.clientId = clientId;\r\n this.logger = logger;\r\n this.callbacks = new Map();\r\n this.eventsByCorrelationId = new Map();\r\n this.measurementsById = new Map();\r\n }\r\n \r\n /**\r\n * Starts and returns an platform-specific implementation of IPerformanceMeasurement.\r\n *\r\n * @abstract\r\n * @param {string} measureName\r\n * @param {string} correlationId\r\n * @returns {IPerformanceMeasurement}\r\n */\r\n abstract startPerformanceMeasuremeant(measureName: string, correlationId: string): IPerformanceMeasurement;\r\n \r\n /**\r\n * Generates and returns a unique id, typically a guid.\r\n *\r\n * @abstract\r\n * @returns {string}\r\n */\r\n abstract generateId(): string;\r\n \r\n /**\r\n * Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.\r\n *\r\n * @param {PerformanceEvents} measureName\r\n * @param {?string} [correlationId]\r\n * @returns {InProgressPerformanceEvent}\r\n */\r\n startMeasurement(measureName: PerformanceEvents, correlationId?: string): InProgressPerformanceEvent {\r\n // Generate a placeholder correlation if the request does not provide one\r\n const eventCorrelationId = correlationId || this.generateId();\r\n if (!correlationId) {\r\n this.logger.info(`PerformanceClient: No correlation id provided for ${measureName}, generating`, eventCorrelationId);\r\n }\r\n\r\n this.logger.trace(`PerformanceClient: Performance measurement started for ${measureName}`, eventCorrelationId);\r\n const performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);\r\n performanceMeasurement.startMeasurement();\r\n\r\n const inProgressEvent: PerformanceEvent = {\r\n eventId: this.generateId(),\r\n status: PerformanceEventStatus.InProgress,\r\n authority: this.authority,\r\n libraryName: this.libraryName,\r\n libraryVersion: this.libraryVersion,\r\n appName: this.applicationTelemetry?.appName,\r\n appVersion: this.applicationTelemetry?.appVersion,\r\n clientId: this.clientId,\r\n name: measureName,\r\n startTimeMs: Date.now(),\r\n correlationId: eventCorrelationId\r\n };\r\n\r\n // Store in progress events so they can be discarded if not ended properly\r\n this.cacheEventByCorrelationId(inProgressEvent);\r\n this.cacheMeasurement(inProgressEvent, performanceMeasurement);\r\n\r\n // Return the event and functions the caller can use to properly end/flush the measurement\r\n return {\r\n endMeasurement: (event?: Partial<PerformanceEvent>): PerformanceEvent | null => {\r\n const completedEvent = this.endMeasurement({\r\n // Initial set of event properties\r\n ...inProgressEvent,\r\n // Properties set when event ends\r\n ...event\r\n });\r\n \r\n if (completedEvent) {\r\n // Cache event so that submeasurements can be added downstream\r\n this.cacheEventByCorrelationId(completedEvent);\r\n }\r\n \r\n return completedEvent;\r\n },\r\n flushMeasurement: () => {\r\n return this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);\r\n },\r\n discardMeasurement: () => {\r\n return this.discardMeasurements(inProgressEvent.correlationId);\r\n },\r\n measurement: performanceMeasurement,\r\n event: inProgressEvent\r\n };\r\n \r\n }\r\n \r\n /**\r\n * Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,\r\n * as consumers should instead use the function returned by startMeasurement.\r\n *\r\n * @param {PerformanceEvent} event\r\n * @returns {(PerformanceEvent | null)}\r\n */\r\n endMeasurement(event: PerformanceEvent): PerformanceEvent | null {\r\n const performanceMeasurement = this.measurementsById.get(event.eventId);\r\n if (performanceMeasurement) {\r\n // Immediately delete so that the same event isnt ended twice\r\n this.measurementsById.delete(event.eventId);\r\n performanceMeasurement.endMeasurement();\r\n const durationMs = performanceMeasurement.flushMeasurement();\r\n // null indicates no measurement was taken (e.g. needed performance APIs not present)\r\n if (durationMs !== null) {\r\n this.logger.trace(`PerformanceClient: Performance measurement ended for ${event.name}: ${durationMs} ms`, event.correlationId);\r\n \r\n const completedEvent: PerformanceEvent = {\r\n // Allow duration to be overwritten when event ends (e.g. testing), but not status\r\n durationMs: Math.round(durationMs),\r\n ...event,\r\n status: PerformanceEventStatus.Completed,\r\n };\r\n \r\n return completedEvent;\r\n } else {\r\n this.logger.trace(\"PerformanceClient: Performance measurement not taken\", event.correlationId);\r\n }\r\n } else {\r\n this.logger.trace(`PerformanceClient: Measurement not found for ${event.eventId}`, event.correlationId);\r\n }\r\n\r\n return null;\r\n }\r\n \r\n /**\r\n * Upserts event into event cache.\r\n * First key is the correlation id, second key is the event id.\r\n * Allows for events to be grouped by correlation id,\r\n * and to easily allow for properties on them to be updated.\r\n *\r\n * @private\r\n * @param {PerformanceEvent} event\r\n */\r\n private cacheEventByCorrelationId(event: PerformanceEvent) {\r\n const existingEvents = this.eventsByCorrelationId.get(event.correlationId);\r\n if (existingEvents) {\r\n this.logger.trace(`PerformanceClient: Performance measurement for ${event.name} added/updated`, event.correlationId);\r\n existingEvents.set(event.eventId, event);\r\n } else {\r\n this.logger.trace(`PerformanceClient: Performance measurement for ${event.name} started`, event.correlationId);\r\n this.eventsByCorrelationId.set(event.correlationId, new Map().set(event.eventId, event));\r\n }\r\n }\r\n \r\n /**\r\n * Cache measurements by their id.\r\n *\r\n * @private\r\n * @param {PerformanceEvent} event\r\n * @param {IPerformanceMeasurement} measurement\r\n */\r\n private cacheMeasurement(event: PerformanceEvent, measurement: IPerformanceMeasurement) {\r\n this.measurementsById.set(event.eventId, measurement);\r\n }\r\n \r\n /**\r\n * Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.\r\n *\r\n * @param {PerformanceEvents} measureName\r\n * @param {string} correlationId\r\n */\r\n flushMeasurements(measureName: PerformanceEvents, correlationId: string): void {\r\n this.logger.trace(`PerformanceClient: Performance measurements flushed for ${measureName}`, correlationId);\r\n const eventsForCorrelationId = this.eventsByCorrelationId.get(correlationId);\r\n if (eventsForCorrelationId) {\r\n this.discardMeasurements(correlationId);\r\n \r\n /*\r\n * Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.\r\n * Incomplete submeasurements are likely an instrumentation bug that should be fixed.\r\n * IE only supports Map.forEach.\r\n */\r\n const completedEvents: PerformanceEvent[] = [];\r\n eventsForCorrelationId.forEach(event => {\r\n if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {\r\n this.logger.trace(`PerformanceClient: Incomplete submeasurement ${event.name} found for ${measureName}`, correlationId);\r\n\r\n const completedEvent = this.endMeasurement(event);\r\n if (completedEvent) {\r\n completedEvents.push(completedEvent);\r\n }\r\n }\r\n\r\n completedEvents.push(event);\r\n });\r\n\r\n // Sort events by start time (earliest first)\r\n const sortedCompletedEvents = completedEvents.sort((eventA, eventB) => eventA.startTimeMs - eventB.startTimeMs);\r\n\r\n // Take completed top level event and add completed submeasurements durations as properties\r\n const topLevelEvents = sortedCompletedEvents.filter(event => event.name === measureName && event.status === PerformanceEventStatus.Completed);\r\n if (topLevelEvents.length > 0) {\r\n /*\r\n * Only take the first top-level event if there are multiple events with the same correlation id.\r\n * This greatly simplifies logic for submeasurements.\r\n */\r\n if (topLevelEvents.length > 1) {\r\n this.logger.verbose(\"PerformanceClient: Multiple distinct top-level performance events found, using the first\", correlationId);\r\n }\r\n const topLevelEvent = topLevelEvents[0];\r\n\r\n this.logger.verbose(`PerformanceClient: Measurement found for ${measureName}`, correlationId);\r\n\r\n // Build event object with top level and sub measurements\r\n const eventToEmit = sortedCompletedEvents.reduce((previous, current) => {\r\n if (current.name !== measureName) {\r\n this.logger.trace(`PerformanceClient: Complete submeasurement found for ${current.name}`, correlationId);\r\n // TODO: Emit additional properties for each subMeasurement\r\n const subMeasurementName = `${current.name}DurationMs`;\r\n /*\r\n * Some code paths, such as resolving an authority, can occur multiple times.\r\n * Only take the first measurement, since the second could be read from the cache,\r\n * or due to the same correlation id being used for two distinct requests.\r\n */\r\n if (!previous[subMeasurementName]) {\r\n previous[subMeasurementName] = current.durationMs;\r\n } else {\r\n this.logger.verbose(`PerformanceClient: Submeasurement for ${measureName} already exists for ${current.name}, ignoring`, correlationId);\r\n }\r\n }\r\n\r\n return previous;\r\n }, topLevelEvent);\r\n\r\n this.emitEvents([eventToEmit], eventToEmit.correlationId);\r\n } else {\r\n this.logger.verbose(`PerformanceClient: No completed top-level measurements found for ${measureName}`, correlationId);\r\n }\r\n } else {\r\n this.logger.verbose(\"PerformanceClient: No measurements found\", correlationId);\r\n }\r\n }\r\n \r\n /**\r\n * Removes measurements for a given correlation id.\r\n *\r\n * @param {string} correlationId\r\n */\r\n discardMeasurements(correlationId: string): void {\r\n this.logger.trace(\"PerformanceClient: Performance measurements discarded\", correlationId);\r\n this.eventsByCorrelationId.delete(correlationId);\r\n }\r\n \r\n /**\r\n * Registers a callback function to receive performance events.\r\n *\r\n * @param {PerformanceCallbackFunction} callback\r\n * @returns {string}\r\n */\r\n addPerformanceCallback(callback: PerformanceCallbackFunction): string {\r\n const callbackId = this.generateId();\r\n this.callbacks.set(callbackId, callback);\r\n this.logger.verbose(`PerformanceClient: Performance callback registered with id: ${callbackId}`);\r\n\r\n return callbackId;\r\n }\r\n \r\n /**\r\n * Removes a callback registered with addPerformanceCallback.\r\n *\r\n * @param {string} callbackId\r\n * @returns {boolean}\r\n */\r\n removePerformanceCallback(callbackId: string): boolean {\r\n const result = this.callbacks.delete(callbackId);\r\n\r\n if (result) {\r\n this.logger.verbose(`PerformanceClient: Performance callback ${callbackId} removed.`);\r\n } else {\r\n this.logger.verbose(`PerformanceClient: Performance callback ${callbackId} not removed.`);\r\n }\r\n \r\n return result;\r\n }\r\n \r\n /**\r\n * Emits events to all registered callbacks.\r\n *\r\n * @param {PerformanceEvent[]} events\r\n * @param {?string} [correlationId]\r\n */\r\n emitEvents(events: PerformanceEvent[], correlationId: string): void {\r\n this.logger.verbose(\"PerformanceClient: Emitting performance events\", correlationId);\r\n\r\n this.callbacks.forEach((callback: PerformanceCallbackFunction, callbackId: string) => {\r\n this.logger.trace(`PerformanceClient: Emitting event to callback ${callbackId}`, correlationId);\r\n callback.apply(null, [events]);\r\n });\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;;;;;;;;;;IA+CI,2BAAY,QAAgB,EAAE,SAAiB,EAAE,MAAc,EAAE,WAAmB,EAAE,cAAsB,EAAE,oBAA0C;QACpJ,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QAC/B,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QACrC,IAAI,CAAC,oBAAoB,GAAG,oBAAoB,CAAC;QACjD,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,IAAI,GAAG,EAAE,CAAC;QAC3B,IAAI,CAAC,qBAAqB,GAAG,IAAI,GAAG,EAAE,CAAC;QACvC,IAAI,CAAC,gBAAgB,GAAG,IAAI,GAAG,EAAE,CAAC;KACrC;;;;;;;;IA2BD,4CAAgB,GAAhB,UAAiB,WAA8B,EAAE,aAAsB;QAAvE,iBAwDC;;;QAtDG,IAAM,kBAAkB,GAAG,aAAa,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;QAC9D,IAAI,CAAC,aAAa,EAAE;YAChB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,uDAAqD,WAAW,iBAAc,EAAE,kBAAkB,CAAC,CAAC;SACxH;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,4DAA0D,WAAa,EAAE,kBAAkB,CAAC,CAAC;QAC/G,IAAM,sBAAsB,GAAG,IAAI,CAAC,4BAA4B,CAAC,WAA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,CAAC,OAAO,CAAC,gDAAgD,EAAE,aAAa,CAAC,CAAC;QAErF,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,UAAC,QAAqC,EAAE,UAAkB;YAC7E,KAAI,CAAC,MAAM,CAAC,KAAK,CAAC,mDAAiD,UAAY,EAAE,aAAa,CAAC,CAAC;YAChG,QAAQ,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;SAClC,CAAC,CAAC;KACN;IACL,wBAAC;AAAD,CAAC;;;;"}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enumeration of operations that are instrumented by have their performance measured by the PerformanceClient.
|
|
3
|
+
*
|
|
4
|
+
* @export
|
|
5
|
+
* @enum {number}
|
|
6
|
+
*/
|
|
7
|
+
export declare enum PerformanceEvents {
|
|
8
|
+
/**
|
|
9
|
+
* acquireTokenByCode API (msal-browser and msal-node).
|
|
10
|
+
* Used to acquire tokens by trading an authorization code against the token endpoint.
|
|
11
|
+
*/
|
|
12
|
+
AcquireTokenByCode = "acquireTokenByCode",
|
|
13
|
+
/**
|
|
14
|
+
* acquireTokenByRefreshToken API (msal-browser and msal-node).
|
|
15
|
+
* Used to renew an access token using a refresh token against the token endpoint.
|
|
16
|
+
*/
|
|
17
|
+
AcquireTokenByRefreshToken = "acquireTokenByRefreshToken",
|
|
18
|
+
/**
|
|
19
|
+
* acquireTokenSilent API (msal-browser and msal-node).
|
|
20
|
+
* Used to silently acquire a new access token (from the cache or the network).
|
|
21
|
+
*/
|
|
22
|
+
AcquireTokenSilent = "acquireTokenSilent",
|
|
23
|
+
/**
|
|
24
|
+
* acquireTokenSilentAsync (msal-browser).
|
|
25
|
+
* Internal API for acquireTokenSilent.
|
|
26
|
+
*/
|
|
27
|
+
AcquireTokenSilentAsync = "acquireTokenSilentAsync",
|
|
28
|
+
/**
|
|
29
|
+
* acquireTokenPopup (msal-browser).
|
|
30
|
+
* Used to acquire a new access token interactively through pop ups
|
|
31
|
+
*/
|
|
32
|
+
AcquireTokenPopup = "acquireTokenPopup",
|
|
33
|
+
/**
|
|
34
|
+
* getPublicKeyThumbprint API in CryptoOpts class (msal-browser).
|
|
35
|
+
* Used to generate a public/private keypair and generate a public key thumbprint for pop requests.
|
|
36
|
+
*/
|
|
37
|
+
CryptoOptsGetPublicKeyThumbprint = "cryptoOptsGetPublicKeyThumbprint",
|
|
38
|
+
/**
|
|
39
|
+
* signJwt API in CryptoOpts class (msal-browser).
|
|
40
|
+
* Used to signed a pop token.
|
|
41
|
+
*/
|
|
42
|
+
CryptoOptsSignJwt = "cryptoOptsSignJwt",
|
|
43
|
+
/**
|
|
44
|
+
* acquireToken API in the SilentCacheClient class (msal-browser).
|
|
45
|
+
* Used to read access tokens from the cache.
|
|
46
|
+
*/
|
|
47
|
+
SilentCacheClientAcquireToken = "silentCacheClientAcquireToken",
|
|
48
|
+
/**
|
|
49
|
+
* acquireToken API in the SilentIframeClient class (msal-browser).
|
|
50
|
+
* Used to acquire a new set of tokens from the authorize endpoint in a hidden iframe.
|
|
51
|
+
*/
|
|
52
|
+
SilentIframeClientAcquireToken = "silentIframeClientAcquireToken",
|
|
53
|
+
/**
|
|
54
|
+
* acquireToken API in SilentRereshClient (msal-browser).
|
|
55
|
+
* Used to acquire a new set of tokens from the token endpoint using a refresh token.
|
|
56
|
+
*/
|
|
57
|
+
SilentRefreshClientAcquireToken = "silentRefreshClientAcquireToken",
|
|
58
|
+
/**
|
|
59
|
+
* ssoSilent API (msal-browser).
|
|
60
|
+
* Used to silently acquire an authorization code and set of tokens using a hidden iframe.
|
|
61
|
+
*/
|
|
62
|
+
SsoSilent = "ssoSilent",
|
|
63
|
+
/**
|
|
64
|
+
* getDiscoveredAuthority API in StandardInteractionClient class (msal-browser).
|
|
65
|
+
* Used to load authority metadata for a request.
|
|
66
|
+
*/
|
|
67
|
+
StandardInteractionClientGetDiscoveredAuthority = "standardInteractionClientGetDiscoveredAuthority",
|
|
68
|
+
/**
|
|
69
|
+
* acquireToken APIs in msal-browser.
|
|
70
|
+
* Used to make an /authorize endpoint call with native brokering enabled.
|
|
71
|
+
*/
|
|
72
|
+
FetchAccountIdWithNativeBroker = "fetchAccountIdWithNativeBroker",
|
|
73
|
+
/**
|
|
74
|
+
* acquireToken API in NativeInteractionClient class (msal-browser).
|
|
75
|
+
* Used to acquire a token from Native component when native brokering is enabled.
|
|
76
|
+
*/
|
|
77
|
+
NativeInteractionClientAcquireToken = "nativeInteractionClientAcquireToken"
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* State of the performance event.
|
|
81
|
+
*
|
|
82
|
+
* @export
|
|
83
|
+
* @enum {number}
|
|
84
|
+
*/
|
|
85
|
+
export declare enum PerformanceEventStatus {
|
|
86
|
+
NotStarted = 0,
|
|
87
|
+
InProgress = 1,
|
|
88
|
+
Completed = 2
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Performance measurement taken by the library, including metadata about the request and application.
|
|
92
|
+
*
|
|
93
|
+
* @export
|
|
94
|
+
* @typedef {PerformanceEvent}
|
|
95
|
+
*/
|
|
96
|
+
export declare type PerformanceEvent = {
|
|
97
|
+
/**
|
|
98
|
+
* Unique id for the event
|
|
99
|
+
*
|
|
100
|
+
* @type {string}
|
|
101
|
+
*/
|
|
102
|
+
eventId: string;
|
|
103
|
+
/**
|
|
104
|
+
* State of the perforance measure.
|
|
105
|
+
*
|
|
106
|
+
* @type {PerformanceEventStatus}
|
|
107
|
+
*/
|
|
108
|
+
status: PerformanceEventStatus;
|
|
109
|
+
/**
|
|
110
|
+
* Login authority used for the request
|
|
111
|
+
*
|
|
112
|
+
* @type {string}
|
|
113
|
+
*/
|
|
114
|
+
authority: string;
|
|
115
|
+
/**
|
|
116
|
+
* Client id for the application
|
|
117
|
+
*
|
|
118
|
+
* @type {string}
|
|
119
|
+
*/
|
|
120
|
+
clientId: string;
|
|
121
|
+
/**
|
|
122
|
+
* Correlation ID used for the request
|
|
123
|
+
*
|
|
124
|
+
* @type {string}
|
|
125
|
+
*/
|
|
126
|
+
correlationId: string;
|
|
127
|
+
/**
|
|
128
|
+
* End-to-end duration in milliseconds.
|
|
129
|
+
* @date 3/22/2022 - 3:40:05 PM
|
|
130
|
+
*
|
|
131
|
+
* @type {number}
|
|
132
|
+
*/
|
|
133
|
+
durationMs?: number;
|
|
134
|
+
/**
|
|
135
|
+
* Visibility of the page when the event completed.
|
|
136
|
+
* Read from: https://developer.mozilla.org/docs/Web/API/Page_Visibility_API
|
|
137
|
+
*
|
|
138
|
+
* @type {?(string | null)}
|
|
139
|
+
*/
|
|
140
|
+
endPageVisibility?: string | null;
|
|
141
|
+
/**
|
|
142
|
+
* Whether the result was retrieved from the cache.
|
|
143
|
+
*
|
|
144
|
+
* @type {(boolean | null)}
|
|
145
|
+
*/
|
|
146
|
+
fromCache?: boolean | null;
|
|
147
|
+
/**
|
|
148
|
+
* Event name (usually in the form of classNameFunctionName)
|
|
149
|
+
*
|
|
150
|
+
* @type {PerformanceEvents}
|
|
151
|
+
*/
|
|
152
|
+
name: PerformanceEvents;
|
|
153
|
+
/**
|
|
154
|
+
* Visibility of the page when the event completed.
|
|
155
|
+
* Read from: https://developer.mozilla.org/docs/Web/API/Page_Visibility_API
|
|
156
|
+
*
|
|
157
|
+
* @type {?(string | null)}
|
|
158
|
+
*/
|
|
159
|
+
startPageVisibility?: string | null;
|
|
160
|
+
/**
|
|
161
|
+
* Unix millisecond timestamp when the event was initiated.
|
|
162
|
+
*
|
|
163
|
+
* @type {number}
|
|
164
|
+
*/
|
|
165
|
+
startTimeMs: number;
|
|
166
|
+
/**
|
|
167
|
+
* Whether or the operation completed successfully.
|
|
168
|
+
*
|
|
169
|
+
* @type {(boolean | null)}
|
|
170
|
+
*/
|
|
171
|
+
success?: boolean | null;
|
|
172
|
+
/**
|
|
173
|
+
* Name of the library used for the operation.
|
|
174
|
+
*
|
|
175
|
+
* @type {string}
|
|
176
|
+
*/
|
|
177
|
+
libraryName: string;
|
|
178
|
+
/**
|
|
179
|
+
* Version of the library used for the operation.
|
|
180
|
+
*
|
|
181
|
+
* @type {string}
|
|
182
|
+
*/
|
|
183
|
+
libraryVersion: string;
|
|
184
|
+
/**
|
|
185
|
+
* Application name as specified by the app.
|
|
186
|
+
*
|
|
187
|
+
* @type {?string}
|
|
188
|
+
*/
|
|
189
|
+
appName?: string;
|
|
190
|
+
/**
|
|
191
|
+
* Application version as specified by the app.
|
|
192
|
+
*
|
|
193
|
+
* @type {?string}
|
|
194
|
+
*/
|
|
195
|
+
appVersion?: string;
|
|
196
|
+
/**
|
|
197
|
+
* Whether the response is from a native component (e.g., WAM)
|
|
198
|
+
*
|
|
199
|
+
* @type {?boolean}
|
|
200
|
+
*/
|
|
201
|
+
isNativeBroker?: boolean;
|
|
202
|
+
};
|
|
203
|
+
//# sourceMappingURL=PerformanceEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PerformanceEvent.d.ts","sourceRoot":"","sources":["../../../src/telemetry/performance/PerformanceEvent.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,oBAAY,iBAAiB;IAEzB;;;OAGG;IACH,kBAAkB,uBAAuB;IAEzC;;;OAGG;IACH,0BAA0B,+BAA+B;IAEzD;;;OAGG;IACH,kBAAkB,uBAAuB;IAEzC;;;OAGG;IACH,uBAAuB,4BAA4B;IAEnD;;;OAGG;IACH,iBAAiB,sBAAsB;IAEvC;;;OAGG;IACH,gCAAgC,qCAAqC;IAErE;;;OAGG;IACH,iBAAiB,sBAAsB;IAEvC;;;OAGG;IACH,6BAA6B,kCAAkC;IAE/D;;;OAGG;IACH,8BAA8B,mCAAmC;IAEjE;;;OAGG;IACH,+BAA+B,oCAAoC;IAEnE;;;OAGG;IACH,SAAS,cAAc;IAEvB;;;OAGG;IACH,+CAA+C,oDAAoD;IAEnG;;;OAGG;IACH,8BAA8B,mCAAmC;IAEjE;;;OAGG;IACH,mCAAmC,wCAAwC;CAC9E;AAED;;;;;G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