@azure/msal-common 10.0.0 → 11.0.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/_virtual/_tslib.js +1 -1
- package/dist/account/AuthToken.js +1 -1
- package/dist/account/CcsCredential.js +1 -1
- package/dist/account/ClientInfo.js +1 -1
- package/dist/authority/Authority.js +1 -1
- package/dist/authority/AuthorityFactory.js +1 -1
- package/dist/authority/AuthorityMetadata.js +1 -1
- package/dist/authority/AuthorityOptions.js +1 -1
- package/dist/authority/AuthorityType.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryErrorResponse.js +1 -1
- package/dist/authority/CloudInstanceDiscoveryResponse.js +1 -1
- package/dist/authority/OpenIdConfigResponse.js +1 -1
- package/dist/authority/ProtocolMode.js +1 -1
- package/dist/authority/RegionDiscovery.js +1 -1
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts +16 -0
- package/dist/broker/nativeBroker/INativeBrokerPlugin.d.ts.map +1 -0
- package/dist/cache/CacheManager.js +2 -2
- package/dist/cache/CacheManager.js.map +1 -1
- package/dist/cache/entities/AccessTokenEntity.js +1 -1
- package/dist/cache/entities/AccountEntity.js +1 -1
- package/dist/cache/entities/AppMetadataEntity.js +1 -1
- package/dist/cache/entities/AuthorityMetadataEntity.js +1 -1
- package/dist/cache/entities/CacheRecord.js +1 -1
- package/dist/cache/entities/CredentialEntity.d.ts.map +1 -1
- package/dist/cache/entities/CredentialEntity.js +6 -3
- package/dist/cache/entities/CredentialEntity.js.map +1 -1
- package/dist/cache/entities/IdTokenEntity.js +1 -1
- package/dist/cache/entities/RefreshTokenEntity.js +1 -1
- package/dist/cache/entities/ServerTelemetryEntity.js +1 -1
- package/dist/cache/entities/ThrottlingEntity.js +1 -1
- package/dist/cache/persistence/TokenCacheContext.js +1 -1
- package/dist/client/AuthorizationCodeClient.js +1 -1
- package/dist/client/BaseClient.js +1 -1
- package/dist/client/ClientCredentialClient.js +1 -1
- package/dist/client/DeviceCodeClient.js +1 -1
- package/dist/client/OnBehalfOfClient.js +1 -1
- package/dist/client/RefreshTokenClient.js +1 -1
- package/dist/client/SilentFlowClient.js +1 -1
- package/dist/client/UsernamePasswordClient.js +1 -1
- package/dist/config/ClientConfiguration.js +1 -1
- package/dist/crypto/ICrypto.js +1 -1
- package/dist/crypto/JoseHeader.js +3 -3
- package/dist/crypto/JoseHeader.js.map +1 -1
- package/dist/crypto/PopTokenGenerator.js +1 -1
- package/dist/error/AuthError.js +1 -1
- package/dist/error/ClientAuthError.d.ts +16 -0
- package/dist/error/ClientAuthError.d.ts.map +1 -1
- package/dist/error/ClientAuthError.js +21 -1
- package/dist/error/ClientAuthError.js.map +1 -1
- package/dist/error/ClientConfigurationError.js +1 -1
- package/dist/error/InteractionRequiredAuthError.js +1 -1
- package/dist/error/JoseHeaderError.js +1 -1
- package/dist/error/ServerError.js +1 -1
- package/dist/index.cjs.js +132 -184
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/logger/Logger.js +1 -1
- package/dist/network/INetworkModule.js +1 -1
- package/dist/network/NetworkManager.d.ts +11 -0
- package/dist/network/NetworkManager.d.ts.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/packageMetadata.d.ts +1 -1
- package/dist/packageMetadata.js +2 -2
- package/dist/packageMetadata.js.map +1 -1
- package/dist/request/AuthenticationHeaderParser.js +1 -1
- package/dist/request/NativeRequest.d.ts +20 -0
- package/dist/request/NativeRequest.d.ts.map +1 -0
- package/dist/request/NativeSignOutRequest.d.ts +6 -0
- package/dist/request/NativeSignOutRequest.d.ts.map +1 -0
- package/dist/request/RequestParameterBuilder.js +1 -1
- package/dist/request/RequestValidator.js +1 -1
- package/dist/request/ScopeSet.js +1 -1
- package/dist/response/ResponseHandler.d.ts +1 -1
- package/dist/response/ResponseHandler.d.ts.map +1 -1
- package/dist/response/ResponseHandler.js +8 -4
- package/dist/response/ResponseHandler.js.map +1 -1
- package/dist/response/ServerAuthorizationTokenResponse.d.ts +1 -0
- package/dist/response/ServerAuthorizationTokenResponse.d.ts.map +1 -1
- package/dist/telemetry/performance/IPerformanceClient.d.ts +5 -3
- package/dist/telemetry/performance/IPerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.d.ts +18 -41
- package/dist/telemetry/performance/PerformanceClient.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceClient.js +93 -175
- package/dist/telemetry/performance/PerformanceClient.js.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.d.ts +28 -5
- package/dist/telemetry/performance/PerformanceEvent.d.ts.map +1 -1
- package/dist/telemetry/performance/PerformanceEvent.js +3 -1
- package/dist/telemetry/performance/PerformanceEvent.js.map +1 -1
- package/dist/telemetry/performance/StubPerformanceClient.js +1 -1
- package/dist/telemetry/server/ServerTelemetryManager.js +1 -1
- package/dist/url/UrlString.js +1 -1
- package/dist/utils/Constants.d.ts +2 -1
- package/dist/utils/Constants.d.ts.map +1 -1
- package/dist/utils/Constants.js +2 -1
- package/dist/utils/Constants.js.map +1 -1
- package/dist/utils/ProtocolUtils.js +1 -1
- package/dist/utils/StringUtils.js +1 -1
- package/dist/utils/TimeUtils.js +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,10 @@ import { Logger } from "../../logger/Logger";
|
|
|
3
3
|
import { InProgressPerformanceEvent, IPerformanceClient, PerformanceCallbackFunction, QueueMeasurement } from "./IPerformanceClient";
|
|
4
4
|
import { IPerformanceMeasurement } from "./IPerformanceMeasurement";
|
|
5
5
|
import { Counters, PerformanceEvent, PerformanceEvents, StaticFields } from "./PerformanceEvent";
|
|
6
|
+
export interface PreQueueEvent {
|
|
7
|
+
name: PerformanceEvents;
|
|
8
|
+
time: number;
|
|
9
|
+
}
|
|
6
10
|
export declare abstract class PerformanceClient implements IPerformanceClient {
|
|
7
11
|
protected authority: string;
|
|
8
12
|
protected libraryName: string;
|
|
@@ -13,34 +17,17 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
|
|
|
13
17
|
protected callbacks: Map<string, PerformanceCallbackFunction>;
|
|
14
18
|
/**
|
|
15
19
|
* Multiple events with the same correlation id.
|
|
16
|
-
* Double keyed by correlation id and event id.
|
|
17
20
|
* @protected
|
|
18
|
-
* @type {Map<string,
|
|
19
|
-
*/
|
|
20
|
-
protected eventsByCorrelationId: Map<string, Map<string, PerformanceEvent>>;
|
|
21
|
-
/**
|
|
22
|
-
* Fields to be emitted which are scoped to the top level request and whose value will not change in submeasurements
|
|
23
|
-
* For example: App name, version, etc.
|
|
21
|
+
* @type {Map<string, PerformanceEvent>}
|
|
24
22
|
*/
|
|
25
|
-
protected
|
|
26
|
-
/**
|
|
27
|
-
* Counters to be emitted which are scoped to the top level request and whose value may change in sub-measurements
|
|
28
|
-
*/
|
|
29
|
-
protected countersByCorrelationId: Map<string, Counters>;
|
|
30
|
-
/**
|
|
31
|
-
* Underlying performance measurements for each operation
|
|
32
|
-
*
|
|
33
|
-
* @protected
|
|
34
|
-
* @type {Map<string, IPerformanceMeasurement>}
|
|
35
|
-
*/
|
|
36
|
-
protected measurementsById: Map<string, IPerformanceMeasurement>;
|
|
23
|
+
protected eventsByCorrelationId: Map<string, PerformanceEvent>;
|
|
37
24
|
/**
|
|
38
25
|
* Map of pre-queue times by correlation Id
|
|
39
26
|
*
|
|
40
27
|
* @protected
|
|
41
|
-
* @type {Map<string,
|
|
28
|
+
* @type {Map<string, PreQueueEvent>}
|
|
42
29
|
*/
|
|
43
|
-
protected preQueueTimeByCorrelationId: Map<string,
|
|
30
|
+
protected preQueueTimeByCorrelationId: Map<string, PreQueueEvent>;
|
|
44
31
|
/**
|
|
45
32
|
* Map of queue measurements by correlation Id
|
|
46
33
|
*
|
|
@@ -119,12 +106,13 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
|
|
|
119
106
|
/**
|
|
120
107
|
* Adds queue measurement time to QueueMeasurements array for given correlation ID.
|
|
121
108
|
*
|
|
122
|
-
* @param {PerformanceEvents}
|
|
109
|
+
* @param {PerformanceEvents} eventName
|
|
123
110
|
* @param {?string} correlationId
|
|
124
|
-
* @param {?number}
|
|
111
|
+
* @param {?number} queueTime
|
|
112
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
125
113
|
* @returns
|
|
126
114
|
*/
|
|
127
|
-
addQueueMeasurement(eventName: PerformanceEvents, correlationId?: string, queueTime?: number): void;
|
|
115
|
+
addQueueMeasurement(eventName: PerformanceEvents, correlationId?: string, queueTime?: number, manuallyCompleted?: boolean): void;
|
|
128
116
|
/**
|
|
129
117
|
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
130
118
|
*
|
|
@@ -136,11 +124,14 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
|
|
|
136
124
|
/**
|
|
137
125
|
* Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
|
|
138
126
|
* as consumers should instead use the function returned by startMeasurement.
|
|
127
|
+
* Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
|
|
128
|
+
* otherwise.
|
|
139
129
|
*
|
|
140
130
|
* @param {PerformanceEvent} event
|
|
131
|
+
* @param {IPerformanceMeasurement} measurement
|
|
141
132
|
* @returns {(PerformanceEvent | null)}
|
|
142
133
|
*/
|
|
143
|
-
endMeasurement(event: PerformanceEvent): PerformanceEvent | null;
|
|
134
|
+
endMeasurement(event: PerformanceEvent, measurement?: IPerformanceMeasurement): PerformanceEvent | null;
|
|
144
135
|
/**
|
|
145
136
|
* Saves extra information to be emitted when the measurements are flushed
|
|
146
137
|
* @param fields
|
|
@@ -163,21 +154,7 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
|
|
|
163
154
|
* @param {PerformanceEvent} event
|
|
164
155
|
*/
|
|
165
156
|
private cacheEventByCorrelationId;
|
|
166
|
-
|
|
167
|
-
* Cache measurements by their id.
|
|
168
|
-
*
|
|
169
|
-
* @private
|
|
170
|
-
* @param {PerformanceEvent} event
|
|
171
|
-
* @param {IPerformanceMeasurement} measurement
|
|
172
|
-
*/
|
|
173
|
-
private cacheMeasurement;
|
|
174
|
-
/**
|
|
175
|
-
* Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
|
|
176
|
-
*
|
|
177
|
-
* @param {PerformanceEvents} measureName
|
|
178
|
-
* @param {string} correlationId
|
|
179
|
-
*/
|
|
180
|
-
flushMeasurements(measureName: PerformanceEvents, correlationId: string): void;
|
|
157
|
+
private getQueueInfo;
|
|
181
158
|
/**
|
|
182
159
|
* Removes measurements for a given correlation id.
|
|
183
160
|
*
|
|
@@ -187,7 +164,7 @@ export declare abstract class PerformanceClient implements IPerformanceClient {
|
|
|
187
164
|
/**
|
|
188
165
|
* Removes cache for a given correlation id.
|
|
189
166
|
*
|
|
190
|
-
* @param {string} correlation identifier
|
|
167
|
+
* @param {string} correlationId correlation identifier
|
|
191
168
|
*/
|
|
192
169
|
private discardCache;
|
|
193
170
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PerformanceClient.d.ts","sourceRoot":"","sources":["../../../src/telemetry/performance/PerformanceClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"PerformanceClient.d.ts","sourceRoot":"","sources":["../../../src/telemetry/performance/PerformanceClient.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kCAAkC,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EACH,0BAA0B,EAC1B,kBAAkB,EAClB,2BAA2B,EAC3B,gBAAgB,EACnB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,uBAA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Q,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;IASnE;;;;OAIG;IACH,OAAO,CAAC,sBAAsB;CAOjC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @azure/msal-common
|
|
1
|
+
/*! @azure/msal-common v11.0.0 2023-03-07 */
|
|
2
2
|
'use strict';
|
|
3
3
|
import { __assign } from '../../_virtual/_tslib.js';
|
|
4
4
|
import { IntFields, PerformanceEventStatus } from './PerformanceEvent.js';
|
|
@@ -28,11 +28,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
28
28
|
this.logger = logger;
|
|
29
29
|
this.callbacks = new Map();
|
|
30
30
|
this.eventsByCorrelationId = new Map();
|
|
31
|
-
this.staticFieldsByCorrelationId = new Map();
|
|
32
|
-
this.measurementsById = new Map();
|
|
33
31
|
this.queueMeasurements = new Map();
|
|
34
32
|
this.preQueueTimeByCorrelationId = new Map();
|
|
35
|
-
this.countersByCorrelationId = new Map();
|
|
36
33
|
}
|
|
37
34
|
/**
|
|
38
35
|
* Starts and returns an platform-specific implementation of IPerformanceMeasurement.
|
|
@@ -73,16 +70,16 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
73
70
|
* @returns {number}
|
|
74
71
|
*/
|
|
75
72
|
PerformanceClient.prototype.getPreQueueTime = function (eventName, correlationId) {
|
|
76
|
-
var
|
|
77
|
-
if (!
|
|
73
|
+
var preQueueEvent = this.preQueueTimeByCorrelationId.get(correlationId);
|
|
74
|
+
if (!preQueueEvent) {
|
|
78
75
|
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue times found for correlationId: " + correlationId + ", unable to add queue measurement");
|
|
79
76
|
return;
|
|
80
77
|
}
|
|
81
|
-
else if (
|
|
78
|
+
else if (preQueueEvent.name !== eventName) {
|
|
82
79
|
this.logger.trace("PerformanceClient.getPreQueueTime: no pre-queue time found for " + eventName + ", unable to add queue measurement");
|
|
83
80
|
return;
|
|
84
81
|
}
|
|
85
|
-
return
|
|
82
|
+
return preQueueEvent.time;
|
|
86
83
|
};
|
|
87
84
|
/**
|
|
88
85
|
* Calculates the difference between current time and time when function was queued.
|
|
@@ -110,12 +107,13 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
110
107
|
/**
|
|
111
108
|
* Adds queue measurement time to QueueMeasurements array for given correlation ID.
|
|
112
109
|
*
|
|
113
|
-
* @param {PerformanceEvents}
|
|
110
|
+
* @param {PerformanceEvents} eventName
|
|
114
111
|
* @param {?string} correlationId
|
|
115
|
-
* @param {?number}
|
|
112
|
+
* @param {?number} queueTime
|
|
113
|
+
* @param {?boolean} manuallyCompleted - indicator for manually completed queue measurements
|
|
116
114
|
* @returns
|
|
117
115
|
*/
|
|
118
|
-
PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime) {
|
|
116
|
+
PerformanceClient.prototype.addQueueMeasurement = function (eventName, correlationId, queueTime, manuallyCompleted) {
|
|
119
117
|
if (!correlationId) {
|
|
120
118
|
this.logger.trace("PerformanceClient.addQueueMeasurement: correlationId not provided for " + eventName + ", cannot add queue measurement");
|
|
121
119
|
return;
|
|
@@ -128,7 +126,7 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
128
126
|
this.logger.trace("PerformanceClient.addQueueMeasurement: no queue time provided for " + eventName);
|
|
129
127
|
return;
|
|
130
128
|
}
|
|
131
|
-
var queueMeasurement = { eventName: eventName, queueTime: queueTime };
|
|
129
|
+
var queueMeasurement = { eventName: eventName, queueTime: queueTime, manuallyCompleted: manuallyCompleted };
|
|
132
130
|
// Adds to existing correlation Id if present in queueMeasurements
|
|
133
131
|
var existingMeasurements = this.queueMeasurements.get(correlationId);
|
|
134
132
|
if (existingMeasurements) {
|
|
@@ -141,6 +139,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
141
139
|
var measurementArray = [queueMeasurement];
|
|
142
140
|
this.queueMeasurements.set(correlationId, measurementArray);
|
|
143
141
|
}
|
|
142
|
+
// Delete processed pre-queue event.
|
|
143
|
+
this.preQueueTimeByCorrelationId.delete(correlationId);
|
|
144
144
|
};
|
|
145
145
|
/**
|
|
146
146
|
* Starts measuring performance for a given operation. Returns a function that should be used to end the measurement.
|
|
@@ -159,17 +159,8 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
159
159
|
}
|
|
160
160
|
// Duplicate code to address spelling error will be removed at the next major version bump.
|
|
161
161
|
this.logger.trace("PerformanceClient: Performance measurement started for " + measureName, eventCorrelationId);
|
|
162
|
-
var
|
|
163
|
-
|
|
164
|
-
if (performanceMeasuremeant.startMeasurement) {
|
|
165
|
-
performanceMeasuremeant.startMeasurement();
|
|
166
|
-
validMeasurement = performanceMeasuremeant;
|
|
167
|
-
}
|
|
168
|
-
else {
|
|
169
|
-
var performanceMeasurement = this.startPerformanceMeasurement(measureName, eventCorrelationId);
|
|
170
|
-
performanceMeasurement.startMeasurement();
|
|
171
|
-
validMeasurement = performanceMeasurement;
|
|
172
|
-
}
|
|
162
|
+
var performanceMeasurement = this.startPerformanceMeasuremeant(measureName, eventCorrelationId);
|
|
163
|
+
performanceMeasurement.startMeasurement();
|
|
173
164
|
var inProgressEvent = {
|
|
174
165
|
eventId: this.generateId(),
|
|
175
166
|
status: PerformanceEventStatus.InProgress,
|
|
@@ -180,27 +171,15 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
180
171
|
name: measureName,
|
|
181
172
|
startTimeMs: Date.now(),
|
|
182
173
|
correlationId: eventCorrelationId,
|
|
183
|
-
};
|
|
184
|
-
// Store in progress events so they can be discarded if not ended properly
|
|
185
|
-
this.cacheEventByCorrelationId(inProgressEvent);
|
|
186
|
-
var staticFields = {
|
|
187
174
|
appName: (_a = this.applicationTelemetry) === null || _a === void 0 ? void 0 : _a.appName,
|
|
188
175
|
appVersion: (_b = this.applicationTelemetry) === null || _b === void 0 ? void 0 : _b.appVersion,
|
|
189
176
|
};
|
|
190
|
-
|
|
191
|
-
this.
|
|
177
|
+
// Store in progress events so they can be discarded if not ended properly
|
|
178
|
+
this.cacheEventByCorrelationId(inProgressEvent);
|
|
192
179
|
// Return the event and functions the caller can use to properly end/flush the measurement
|
|
193
180
|
return {
|
|
194
181
|
endMeasurement: function (event) {
|
|
195
|
-
|
|
196
|
-
if (completedEvent) {
|
|
197
|
-
// Cache event so that submeasurements can be added downstream
|
|
198
|
-
_this.cacheEventByCorrelationId(completedEvent);
|
|
199
|
-
}
|
|
200
|
-
return completedEvent;
|
|
201
|
-
},
|
|
202
|
-
flushMeasurement: function () {
|
|
203
|
-
return _this.flushMeasurements(inProgressEvent.name, inProgressEvent.correlationId);
|
|
182
|
+
return _this.endMeasurement(__assign(__assign({}, inProgressEvent), event), performanceMeasurement);
|
|
204
183
|
},
|
|
205
184
|
discardMeasurement: function () {
|
|
206
185
|
return _this.discardMeasurements(inProgressEvent.correlationId);
|
|
@@ -211,40 +190,66 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
211
190
|
increment: function (counters) {
|
|
212
191
|
return _this.increment(counters, inProgressEvent.correlationId);
|
|
213
192
|
},
|
|
214
|
-
measurement:
|
|
193
|
+
measurement: performanceMeasurement,
|
|
215
194
|
event: inProgressEvent
|
|
216
195
|
};
|
|
217
196
|
};
|
|
218
197
|
/**
|
|
219
198
|
* Stops measuring the performance for an operation. Should only be called directly by PerformanceClient classes,
|
|
220
199
|
* as consumers should instead use the function returned by startMeasurement.
|
|
200
|
+
* Adds a new field named as "[event name]DurationMs" for sub-measurements, completes and emits an event
|
|
201
|
+
* otherwise.
|
|
221
202
|
*
|
|
222
203
|
* @param {PerformanceEvent} event
|
|
204
|
+
* @param {IPerformanceMeasurement} measurement
|
|
223
205
|
* @returns {(PerformanceEvent | null)}
|
|
224
206
|
*/
|
|
225
|
-
PerformanceClient.prototype.endMeasurement = function (event) {
|
|
226
|
-
var
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
}
|
|
207
|
+
PerformanceClient.prototype.endMeasurement = function (event, measurement) {
|
|
208
|
+
var _this = this;
|
|
209
|
+
var _a, _b;
|
|
210
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
211
|
+
if (!rootEvent) {
|
|
212
|
+
this.logger.trace("PerformanceClient: Measurement not found for " + event.eventId, event.correlationId);
|
|
213
|
+
return null;
|
|
214
|
+
}
|
|
215
|
+
var isRoot = event.eventId === rootEvent.eventId;
|
|
216
|
+
var queueInfo = {
|
|
217
|
+
totalQueueTime: 0,
|
|
218
|
+
totalQueueCount: 0,
|
|
219
|
+
manuallyCompletedCount: 0
|
|
220
|
+
};
|
|
221
|
+
if (isRoot) {
|
|
222
|
+
queueInfo = this.getQueueInfo(event.correlationId);
|
|
223
|
+
this.discardCache(rootEvent.correlationId);
|
|
243
224
|
}
|
|
244
225
|
else {
|
|
245
|
-
|
|
226
|
+
(_a = rootEvent.incompleteSubMeasurements) === null || _a === void 0 ? void 0 : _a.delete(event.eventId);
|
|
227
|
+
}
|
|
228
|
+
measurement === null || measurement === void 0 ? void 0 : measurement.endMeasurement();
|
|
229
|
+
var durationMs = measurement === null || measurement === void 0 ? void 0 : measurement.flushMeasurement();
|
|
230
|
+
// null indicates no measurement was taken (e.g. needed performance APIs not present)
|
|
231
|
+
if (!durationMs) {
|
|
232
|
+
this.logger.trace("PerformanceClient: Performance measurement not taken", rootEvent.correlationId);
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
this.logger.trace("PerformanceClient: Performance measurement ended for " + event.name + ": " + durationMs + " ms", event.correlationId);
|
|
236
|
+
// Add sub-measurement attribute to root event.
|
|
237
|
+
if (!isRoot) {
|
|
238
|
+
rootEvent[event.name + "DurationMs"] = Math.floor(durationMs);
|
|
239
|
+
return __assign({}, rootEvent);
|
|
246
240
|
}
|
|
247
|
-
|
|
241
|
+
var finalEvent = __assign(__assign({}, rootEvent), event);
|
|
242
|
+
var incompleteSubsCount = 0;
|
|
243
|
+
// Incomplete sub-measurements are discarded. They are likely an instrumentation bug that should be fixed.
|
|
244
|
+
(_b = finalEvent.incompleteSubMeasurements) === null || _b === void 0 ? void 0 : _b.forEach(function (subMeasurement) {
|
|
245
|
+
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + subMeasurement.name + " found for " + event.name, finalEvent.correlationId);
|
|
246
|
+
incompleteSubsCount++;
|
|
247
|
+
});
|
|
248
|
+
finalEvent.incompleteSubMeasurements = undefined;
|
|
249
|
+
finalEvent = __assign(__assign({}, finalEvent), { durationMs: Math.round(durationMs), queuedTimeMs: queueInfo.totalQueueTime, queuedCount: queueInfo.totalQueueCount, queuedManuallyCompletedCount: queueInfo.manuallyCompletedCount, status: PerformanceEventStatus.Completed, incompleteSubsCount: incompleteSubsCount });
|
|
250
|
+
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
251
|
+
this.emitEvents([finalEvent], event.correlationId);
|
|
252
|
+
return finalEvent;
|
|
248
253
|
};
|
|
249
254
|
/**
|
|
250
255
|
* Saves extra information to be emitted when the measurements are flushed
|
|
@@ -252,14 +257,13 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
252
257
|
* @param correlationId
|
|
253
258
|
*/
|
|
254
259
|
PerformanceClient.prototype.addStaticFields = function (fields, correlationId) {
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
this.
|
|
260
|
+
this.logger.trace("PerformanceClient: Updating static fields");
|
|
261
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
262
|
+
if (event) {
|
|
263
|
+
this.eventsByCorrelationId.set(correlationId, __assign(__assign({}, event), fields));
|
|
259
264
|
}
|
|
260
265
|
else {
|
|
261
|
-
this.logger.trace("PerformanceClient:
|
|
262
|
-
this.staticFieldsByCorrelationId.set(correlationId, fields);
|
|
266
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
263
267
|
}
|
|
264
268
|
};
|
|
265
269
|
/**
|
|
@@ -268,18 +272,18 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
268
272
|
* @param correlationId {string} correlation identifier
|
|
269
273
|
*/
|
|
270
274
|
PerformanceClient.prototype.increment = function (counters, correlationId) {
|
|
271
|
-
var existing = this.countersByCorrelationId.get(correlationId);
|
|
272
|
-
if (!existing) {
|
|
273
|
-
this.logger.trace("PerformanceClient: Setting counters");
|
|
274
|
-
this.countersByCorrelationId.set(correlationId, __assign({}, counters));
|
|
275
|
-
return;
|
|
276
|
-
}
|
|
277
275
|
this.logger.trace("PerformanceClient: Updating counters");
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
276
|
+
var event = this.eventsByCorrelationId.get(correlationId);
|
|
277
|
+
if (event) {
|
|
278
|
+
for (var counter in counters) {
|
|
279
|
+
if (!event.hasOwnProperty(counter)) {
|
|
280
|
+
event[counter] = 0;
|
|
281
|
+
}
|
|
282
|
+
event[counter] += counters[counter];
|
|
281
283
|
}
|
|
282
|
-
|
|
284
|
+
}
|
|
285
|
+
else {
|
|
286
|
+
this.logger.trace("PerformanceClient: Event not found for", correlationId);
|
|
283
287
|
}
|
|
284
288
|
};
|
|
285
289
|
/**
|
|
@@ -292,117 +296,35 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
292
296
|
* @param {PerformanceEvent} event
|
|
293
297
|
*/
|
|
294
298
|
PerformanceClient.prototype.cacheEventByCorrelationId = function (event) {
|
|
295
|
-
var
|
|
296
|
-
if (
|
|
299
|
+
var rootEvent = this.eventsByCorrelationId.get(event.correlationId);
|
|
300
|
+
if (rootEvent) {
|
|
297
301
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " added/updated", event.correlationId);
|
|
298
|
-
|
|
302
|
+
rootEvent.incompleteSubMeasurements = rootEvent.incompleteSubMeasurements || new Map();
|
|
303
|
+
rootEvent.incompleteSubMeasurements.set(event.eventId, { name: event.name, startTimeMs: event.startTimeMs });
|
|
299
304
|
}
|
|
300
305
|
else {
|
|
301
306
|
this.logger.trace("PerformanceClient: Performance measurement for " + event.name + " started", event.correlationId);
|
|
302
|
-
this.eventsByCorrelationId.set(event.correlationId,
|
|
307
|
+
this.eventsByCorrelationId.set(event.correlationId, __assign({}, event));
|
|
303
308
|
}
|
|
304
309
|
};
|
|
305
|
-
|
|
306
|
-
* Cache measurements by their id.
|
|
307
|
-
*
|
|
308
|
-
* @private
|
|
309
|
-
* @param {PerformanceEvent} event
|
|
310
|
-
* @param {IPerformanceMeasurement} measurement
|
|
311
|
-
*/
|
|
312
|
-
PerformanceClient.prototype.cacheMeasurement = function (event, measurement) {
|
|
313
|
-
this.measurementsById.set(event.eventId, measurement);
|
|
314
|
-
};
|
|
315
|
-
/**
|
|
316
|
-
* Gathers and emits performance events for measurements taked for the given top-level API and correlation ID.
|
|
317
|
-
*
|
|
318
|
-
* @param {PerformanceEvents} measureName
|
|
319
|
-
* @param {string} correlationId
|
|
320
|
-
*/
|
|
321
|
-
PerformanceClient.prototype.flushMeasurements = function (measureName, correlationId) {
|
|
322
|
-
var _this = this;
|
|
323
|
-
this.logger.trace("PerformanceClient: Performance measurements flushed for " + measureName, correlationId);
|
|
324
|
-
/**
|
|
325
|
-
* Adds all queue time and count measurements for given correlation ID
|
|
326
|
-
* then deletes queue times for given correlation ID from queueMeasurements map.
|
|
327
|
-
*/
|
|
310
|
+
PerformanceClient.prototype.getQueueInfo = function (correlationId) {
|
|
328
311
|
var queueMeasurementForCorrelationId = this.queueMeasurements.get(correlationId);
|
|
329
312
|
if (!queueMeasurementForCorrelationId) {
|
|
330
313
|
this.logger.trace("PerformanceClient: no queue measurements found for for correlationId: " + correlationId);
|
|
331
314
|
}
|
|
332
315
|
var totalQueueTime = 0;
|
|
333
316
|
var totalQueueCount = 0;
|
|
317
|
+
var manuallyCompletedCount = 0;
|
|
334
318
|
queueMeasurementForCorrelationId === null || queueMeasurementForCorrelationId === void 0 ? void 0 : queueMeasurementForCorrelationId.forEach(function (measurement) {
|
|
335
319
|
totalQueueTime += measurement.queueTime;
|
|
336
320
|
totalQueueCount++;
|
|
321
|
+
manuallyCompletedCount += measurement.manuallyCompleted ? 1 : 0;
|
|
337
322
|
});
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
/*
|
|
344
|
-
* Manually end incomplete submeasurements to ensure there arent orphaned/never ending events.
|
|
345
|
-
* Incomplete submeasurements are likely an instrumentation bug that should be fixed.
|
|
346
|
-
* IE only supports Map.forEach.
|
|
347
|
-
*/
|
|
348
|
-
var completedEvents_1 = [];
|
|
349
|
-
var incompleteSubsCount_1 = 0;
|
|
350
|
-
eventsForCorrelationId.forEach(function (event) {
|
|
351
|
-
if (event.name !== measureName && event.status !== PerformanceEventStatus.Completed) {
|
|
352
|
-
_this.logger.trace("PerformanceClient: Incomplete submeasurement " + event.name + " found for " + measureName, correlationId);
|
|
353
|
-
incompleteSubsCount_1++;
|
|
354
|
-
var completedEvent = _this.endMeasurement(event);
|
|
355
|
-
if (completedEvent) {
|
|
356
|
-
completedEvents_1.push(completedEvent);
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
completedEvents_1.push(event);
|
|
360
|
-
});
|
|
361
|
-
// Sort events by start time (earliest first)
|
|
362
|
-
var sortedCompletedEvents = completedEvents_1.sort(function (eventA, eventB) { return eventA.startTimeMs - eventB.startTimeMs; });
|
|
363
|
-
// Take completed top level event and add completed submeasurements durations as properties
|
|
364
|
-
var topLevelEvents = sortedCompletedEvents.filter(function (event) { return event.name === measureName && event.status === PerformanceEventStatus.Completed; });
|
|
365
|
-
if (topLevelEvents.length > 0) {
|
|
366
|
-
/*
|
|
367
|
-
* Only take the first top-level event if there are multiple events with the same correlation id.
|
|
368
|
-
* This greatly simplifies logic for submeasurements.
|
|
369
|
-
*/
|
|
370
|
-
if (topLevelEvents.length > 1) {
|
|
371
|
-
this.logger.verbose("PerformanceClient: Multiple distinct top-level performance events found, using the first", correlationId);
|
|
372
|
-
}
|
|
373
|
-
var topLevelEvent = topLevelEvents[0];
|
|
374
|
-
this.logger.verbose("PerformanceClient: Measurement found for " + measureName, correlationId);
|
|
375
|
-
// Build event object with top level and sub measurements
|
|
376
|
-
var eventToEmit = sortedCompletedEvents.reduce(function (previous, current) {
|
|
377
|
-
if (current.name !== measureName) {
|
|
378
|
-
_this.logger.trace("PerformanceClient: Complete submeasurement found for " + current.name, correlationId);
|
|
379
|
-
// TODO: Emit additional properties for each subMeasurement
|
|
380
|
-
var subMeasurementName = current.name + "DurationMs";
|
|
381
|
-
/*
|
|
382
|
-
* Some code paths, such as resolving an authority, can occur multiple times.
|
|
383
|
-
* Only take the first measurement, since the second could be read from the cache,
|
|
384
|
-
* or due to the same correlation id being used for two distinct requests.
|
|
385
|
-
*/
|
|
386
|
-
if (!previous[subMeasurementName]) {
|
|
387
|
-
previous[subMeasurementName] = current.durationMs;
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
_this.logger.verbose("PerformanceClient: Submeasurement for " + measureName + " already exists for " + current.name + ", ignoring", correlationId);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
return previous;
|
|
394
|
-
}, topLevelEvent);
|
|
395
|
-
var finalEvent = __assign(__assign(__assign(__assign({}, eventToEmit), staticFields), counters), { queuedTimeMs: totalQueueTime, queuedCount: totalQueueCount, incompleteSubsCount: incompleteSubsCount_1 });
|
|
396
|
-
this.truncateIntegralFields(finalEvent, this.getIntFields());
|
|
397
|
-
this.emitEvents([finalEvent], eventToEmit.correlationId);
|
|
398
|
-
}
|
|
399
|
-
else {
|
|
400
|
-
this.logger.verbose("PerformanceClient: No completed top-level measurements found for " + measureName, correlationId);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
else {
|
|
404
|
-
this.logger.verbose("PerformanceClient: No measurements found", correlationId);
|
|
405
|
-
}
|
|
323
|
+
return {
|
|
324
|
+
totalQueueTime: totalQueueTime,
|
|
325
|
+
totalQueueCount: totalQueueCount,
|
|
326
|
+
manuallyCompletedCount: manuallyCompletedCount
|
|
327
|
+
};
|
|
406
328
|
};
|
|
407
329
|
/**
|
|
408
330
|
* Removes measurements for a given correlation id.
|
|
@@ -416,14 +338,10 @@ var PerformanceClient = /** @class */ (function () {
|
|
|
416
338
|
/**
|
|
417
339
|
* Removes cache for a given correlation id.
|
|
418
340
|
*
|
|
419
|
-
* @param {string} correlation identifier
|
|
341
|
+
* @param {string} correlationId correlation identifier
|
|
420
342
|
*/
|
|
421
343
|
PerformanceClient.prototype.discardCache = function (correlationId) {
|
|
422
344
|
this.discardMeasurements(correlationId);
|
|
423
|
-
this.logger.trace("PerformanceClient: Static fields discarded", correlationId);
|
|
424
|
-
this.staticFieldsByCorrelationId.delete(correlationId);
|
|
425
|
-
this.logger.trace("PerformanceClient: Counters discarded", correlationId);
|
|
426
|
-
this.countersByCorrelationId.delete(correlationId);
|
|
427
345
|
this.logger.trace("PerformanceClient: QueueMeasurements discarded", correlationId);
|
|
428
346
|
this.queueMeasurements.delete(correlationId);
|
|
429
347
|
this.logger.trace("PerformanceClient: Pre-queue times discarded", correlationId);
|