o11y 248.8.0 → 248.9.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/modules/o11y/client/client.js +258 -21
- package/dist/modules/o11y/client/client.js.map +1 -1
- package/dist/modules/o11y/client/interfaces/Activity.d.ts +1 -0
- package/dist/modules/o11y/client/interfaces/NetworkInstrumentationOptions.d.ts +2 -0
- package/dist/modules/o11y/client/library/ActivityImpl.d.ts +1 -0
- package/dist/modules/o11y/client/library/ActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/client/library/FuzzyMapper.d.ts +8 -0
- package/dist/modules/o11y/client/library/PerformanceOfResources.d.ts +27 -0
- package/dist/modules/o11y/client/library/RootActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/client/library/Tracing.d.ts +4 -2
- package/dist/modules/o11y/client/test/TestEnvironment.d.ts +3 -3
- package/dist/modules/o11y/client/types/TypeDefinitions-Private.d.ts +32 -0
- package/dist/modules/o11y/client/version.d.ts +1 -1
- package/dist/modules/o11y/collectors/interfaces/Activity.d.ts +1 -0
- package/dist/modules/o11y/collectors/interfaces/NetworkInstrumentationOptions.d.ts +2 -0
- package/dist/modules/o11y/collectors/library/ActivityImpl.d.ts +1 -0
- package/dist/modules/o11y/collectors/library/ActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/collectors/library/FuzzyMapper.d.ts +8 -0
- package/dist/modules/o11y/collectors/library/PerformanceOfResources.d.ts +27 -0
- package/dist/modules/o11y/collectors/library/RootActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/collectors/library/Tracing.d.ts +4 -2
- package/dist/modules/o11y/collectors/test/TestEnvironment.d.ts +3 -3
- package/dist/modules/o11y/collectors/types/TypeDefinitions-Private.d.ts +32 -0
- package/dist/modules/o11y/collectors/version.d.ts +1 -1
- package/dist/modules/o11y/core_envelope/core_envelope.js +1 -1
- package/dist/modules/o11y/core_envelope/core_envelope.js.map +1 -1
- package/dist/modules/o11y/core_envelope/interfaces/Activity.d.ts +1 -0
- package/dist/modules/o11y/core_envelope/interfaces/NetworkInstrumentationOptions.d.ts +2 -0
- package/dist/modules/o11y/core_envelope/library/ActivityImpl.d.ts +1 -0
- package/dist/modules/o11y/core_envelope/library/ActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/core_envelope/library/FuzzyMapper.d.ts +8 -0
- package/dist/modules/o11y/core_envelope/library/PerformanceOfResources.d.ts +27 -0
- package/dist/modules/o11y/core_envelope/library/RootActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/core_envelope/library/Tracing.d.ts +4 -2
- package/dist/modules/o11y/core_envelope/test/TestEnvironment.d.ts +3 -3
- package/dist/modules/o11y/core_envelope/types/TypeDefinitions-Private.d.ts +32 -0
- package/dist/modules/o11y/core_envelope/version.d.ts +1 -1
- package/dist/modules/o11y/shared/interfaces/Activity.d.ts +1 -0
- package/dist/modules/o11y/shared/interfaces/NetworkInstrumentationOptions.d.ts +2 -0
- package/dist/modules/o11y/shared/library/ActivityImpl.d.ts +1 -0
- package/dist/modules/o11y/shared/library/ActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/shared/library/FuzzyMapper.d.ts +8 -0
- package/dist/modules/o11y/shared/library/PerformanceOfResources.d.ts +27 -0
- package/dist/modules/o11y/shared/library/RootActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/shared/library/Tracing.d.ts +4 -2
- package/dist/modules/o11y/shared/test/TestEnvironment.d.ts +3 -3
- package/dist/modules/o11y/shared/types/TypeDefinitions-Private.d.ts +32 -0
- package/dist/modules/o11y/shared/version.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/interfaces/Activity.d.ts +1 -0
- package/dist/modules/o11y/simple_collector/interfaces/NetworkInstrumentationOptions.d.ts +2 -0
- package/dist/modules/o11y/simple_collector/library/ActivityImpl.d.ts +1 -0
- package/dist/modules/o11y/simple_collector/library/ActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/simple_collector/library/FuzzyMapper.d.ts +8 -0
- package/dist/modules/o11y/simple_collector/library/PerformanceOfResources.d.ts +27 -0
- package/dist/modules/o11y/simple_collector/library/RootActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/simple_collector/library/Tracing.d.ts +4 -2
- package/dist/modules/o11y/simple_collector/test/TestEnvironment.d.ts +3 -3
- package/dist/modules/o11y/simple_collector/types/TypeDefinitions-Private.d.ts +32 -0
- package/dist/modules/o11y/simple_collector/version.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/interfaces/Activity.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/interfaces/NetworkInstrumentationOptions.d.ts +2 -0
- package/dist/modules/o11y/web_vitals/library/ActivityImpl.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/library/ActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/library/FuzzyMapper.d.ts +8 -0
- package/dist/modules/o11y/web_vitals/library/PerformanceOfResources.d.ts +27 -0
- package/dist/modules/o11y/web_vitals/library/RootActivityNoOp.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/library/Tracing.d.ts +4 -2
- package/dist/modules/o11y/web_vitals/test/TestEnvironment.d.ts +3 -3
- package/dist/modules/o11y/web_vitals/types/TypeDefinitions-Private.d.ts +32 -0
- package/dist/modules/o11y/web_vitals/version.d.ts +1 -1
- package/package.json +4 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { simpleSchema, errorSchema, activitySchema, instrumentedEventSchema, idleDetectorReportSchema } from 'o11y_schema/sf_instrumentation';
|
|
1
|
+
import { networkSchema, simpleSchema, errorSchema, activitySchema, instrumentedEventSchema, idleDetectorReportSchema } from 'o11y_schema/sf_instrumentation';
|
|
2
2
|
import { utility, PublicSafety, schemaUtil, maxStringLengthAppLimit, metricsUtility, payloadUtility } from 'o11y/shared';
|
|
3
3
|
|
|
4
4
|
class TaskerImpl {
|
|
@@ -247,6 +247,159 @@ class IdleDetectorImpl {
|
|
|
247
247
|
}
|
|
248
248
|
}
|
|
249
249
|
|
|
250
|
+
const network_request={namespace:"sfcore.network",name:"NetworkRequest",pbjsSchema:{"nested":{"sfcore":{"nested":{"network":{"nested":{"NetworkRequest":{"oneofs":{"_xhrDelay":{"oneof":["xhrDelay"]},"_renderBlockingStatus":{"oneof":["renderBlockingStatus"]},"_firstInterimResponseStart":{"oneof":["firstInterimResponseStart"]},"_srvDuration":{"oneof":["srvDuration"]},"_isCdnCached":{"oneof":["isCdnCached"]},"_dbDuration":{"oneof":["dbDuration"]},"_reqBatchCount":{"oneof":["reqBatchCount"]}},"fields":{"encodedBodySize":{"id":21,
|
|
251
|
+
"type":"uint32"},"reqActionNames":{"rule":"repeated","id":28,"type":"string"},"responseEnd":{"id":19,"type":"double"},"domainLookupEnd":{"id":12,"type":"double"},"firstInterimResponseStart":{"options":{"proto3_optional":true},"id":18,"type":"double"},"duration":{"id":3,"type":"double"},"decodedBodySize":{"id":22,"type":"uint32"},"redirectStart":{"id":8,"type":"double"},"connectEnd":{"id":15,"type":"double"},"isCdnCached":{"options":{"proto3_optional":true},"id":24,"type":"bool"},"requestStart":{"id":16,
|
|
252
|
+
"type":"double"},"startTime":{"id":2,"type":"double"},"fetchStart":{"id":10,"type":"double"},"srvReqId":{"id":29,"type":"string"},"reqBatchCount":{"options":{"proto3_optional":true},"id":27,"type":"uint32"},"renderBlockingStatus":{"options":{"proto3_optional":true},"id":6,"type":"string"},"workerStart":{"id":7,"type":"double"},"responseStart":{"id":17,"type":"double"},"xhrDelay":{"options":{"proto3_optional":true},"id":30,"type":"double"},"domainLookupStart":{"id":11,"type":"double"},"responseStatus":{"id":23,
|
|
253
|
+
"type":"uint32"},"redirectEnd":{"id":9,"type":"double"},"transferSize":{"id":20,"type":"uint32"},"srvDuration":{"options":{"proto3_optional":true},"id":26,"type":"double"},"dbDuration":{"options":{"proto3_optional":true},"id":25,"type":"double"},"connectStart":{"id":13,"type":"double"},"secureConnectionStart":{"id":14,"type":"double"},"name":{"id":1,"type":"string"},"nextHopProtocol":{"id":5,"type":"string"},"initiatorType":{"id":4,"type":"string"}}}}}}}}}};
|
|
254
|
+
|
|
255
|
+
class FuzzyMapper {
|
|
256
|
+
constructor(_fuzzyKeyRange) {
|
|
257
|
+
this._fuzzyKeyRange = _fuzzyKeyRange;
|
|
258
|
+
this._map = new Map();
|
|
259
|
+
utility.requireArgument(_fuzzyKeyRange, '_fuzzyKeyRange', 'number');
|
|
260
|
+
}
|
|
261
|
+
add(key, fuzzyKey, value) {
|
|
262
|
+
const mapValue = this._map.get(key);
|
|
263
|
+
if (mapValue) {
|
|
264
|
+
mapValue.push({ fuzzyKey, value });
|
|
265
|
+
}
|
|
266
|
+
else {
|
|
267
|
+
this._map.set(key, [{ fuzzyKey, value }]);
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
pop(key, fuzzyKey) {
|
|
271
|
+
const mapValues = this._map.get(key);
|
|
272
|
+
if ((mapValues === null || mapValues === void 0 ? void 0 : mapValues.length) >= 1) {
|
|
273
|
+
let minDelta = Number.POSITIVE_INFINITY;
|
|
274
|
+
let minIndex = -1;
|
|
275
|
+
for (let index = 0; index < mapValues.length; index++) {
|
|
276
|
+
const { fuzzyKey: curFuzzyKey } = mapValues[index];
|
|
277
|
+
const curDelta = Math.abs(curFuzzyKey - fuzzyKey);
|
|
278
|
+
if (curDelta <= this._fuzzyKeyRange && curDelta < minDelta) {
|
|
279
|
+
minDelta = curDelta;
|
|
280
|
+
minIndex = index;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
if (minIndex >= 0) {
|
|
284
|
+
const { value } = mapValues.splice(minIndex, 1)[0];
|
|
285
|
+
if (mapValues.length === 0) {
|
|
286
|
+
this._map.delete(key);
|
|
287
|
+
}
|
|
288
|
+
return value;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
return undefined;
|
|
292
|
+
}
|
|
293
|
+
clear() {
|
|
294
|
+
this._map.clear();
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
const basicInitiatorTypes = ['fetch', 'xmlhttprequest'];
|
|
299
|
+
class PerformanceOfResources {
|
|
300
|
+
constructor(_instr, _logResourceTimingActivityName, logLevel) {
|
|
301
|
+
this._instr = _instr;
|
|
302
|
+
this._logResourceTimingActivityName = _logResourceTimingActivityName;
|
|
303
|
+
this._fuzzyMapper = new FuzzyMapper(50);
|
|
304
|
+
this._isStarted = false;
|
|
305
|
+
this._hasPerf =
|
|
306
|
+
typeof performance !== 'undefined' && typeof PerformanceObserver === 'function';
|
|
307
|
+
this._observerCallback = this._logResourceTimingEntries.bind(this);
|
|
308
|
+
if (!logLevel || logLevel.toLowerCase() === 'full') {
|
|
309
|
+
this._logLevel = 1;
|
|
310
|
+
}
|
|
311
|
+
else if ((logLevel === null || logLevel === void 0 ? void 0 : logLevel.toLowerCase()) === 'basic') {
|
|
312
|
+
this._logLevel = 0;
|
|
313
|
+
}
|
|
314
|
+
else {
|
|
315
|
+
throw new Error(`Invalid log level: ${logLevel}`);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
get isStarted() {
|
|
319
|
+
return this._isStarted;
|
|
320
|
+
}
|
|
321
|
+
start() {
|
|
322
|
+
if (!this._hasPerf) {
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (!this._isStarted) {
|
|
326
|
+
this._isStarted = true;
|
|
327
|
+
this._observer = new PerformanceObserver(this._observerCallback);
|
|
328
|
+
this._observer.observe({ entryTypes: ['resource'], buffered: true });
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
stop() {
|
|
332
|
+
if (this._observer) {
|
|
333
|
+
this._observer.disconnect();
|
|
334
|
+
this._observer = undefined;
|
|
335
|
+
}
|
|
336
|
+
this._fuzzyMapper.clear();
|
|
337
|
+
this._isStarted = false;
|
|
338
|
+
}
|
|
339
|
+
addEntry(url, perfTime, data) {
|
|
340
|
+
this._fuzzyMapper.add(url, perfTime, data);
|
|
341
|
+
}
|
|
342
|
+
_resourceEntryToNetworkType(prt) {
|
|
343
|
+
var _a, _b;
|
|
344
|
+
const requestInfo = this._fuzzyMapper.pop(prt.name, prt.startTime);
|
|
345
|
+
const nr = {
|
|
346
|
+
name: prt.name,
|
|
347
|
+
startTime: prt.startTime,
|
|
348
|
+
duration: prt.duration,
|
|
349
|
+
initiatorType: prt.initiatorType,
|
|
350
|
+
nextHopProtocol: prt.nextHopProtocol,
|
|
351
|
+
renderBlockingStatus: prt.renderBlockingStatus,
|
|
352
|
+
workerStart: prt.workerStart,
|
|
353
|
+
redirectStart: prt.redirectStart,
|
|
354
|
+
redirectEnd: prt.redirectEnd,
|
|
355
|
+
fetchStart: prt.fetchStart,
|
|
356
|
+
domainLookupStart: prt.domainLookupStart,
|
|
357
|
+
domainLookupEnd: prt.domainLookupEnd,
|
|
358
|
+
connectStart: prt.connectStart,
|
|
359
|
+
secureConnectionStart: prt.secureConnectionStart,
|
|
360
|
+
connectEnd: prt.connectEnd,
|
|
361
|
+
requestStart: prt.requestStart,
|
|
362
|
+
responseStart: prt.responseStart,
|
|
363
|
+
firstInterimResponseStart: prt.firstInterimResponseStart,
|
|
364
|
+
responseEnd: prt.responseEnd,
|
|
365
|
+
transferSize: prt.transferSize,
|
|
366
|
+
encodedBodySize: prt.encodedBodySize,
|
|
367
|
+
decodedBodySize: prt.decodedBodySize,
|
|
368
|
+
responseStatus: prt.responseStatus,
|
|
369
|
+
srvReqId: requestInfo === null || requestInfo === void 0 ? void 0 : requestInfo.requestId,
|
|
370
|
+
xhrDelay: requestInfo
|
|
371
|
+
? requestInfo.activityDuration - (prt.startTime + prt.duration)
|
|
372
|
+
: undefined
|
|
373
|
+
};
|
|
374
|
+
const sts = prt.serverTiming;
|
|
375
|
+
if (Array.isArray(sts)) {
|
|
376
|
+
nr.dbDuration = (_a = sts.find((st) => st.name === 'db')) === null || _a === void 0 ? void 0 : _a.duration;
|
|
377
|
+
nr.srvDuration = (_b = sts.find((st) => st.name === 'Total')) === null || _b === void 0 ? void 0 : _b.duration;
|
|
378
|
+
}
|
|
379
|
+
return nr;
|
|
380
|
+
}
|
|
381
|
+
_shouldInclude(entry) {
|
|
382
|
+
if (this._logLevel === 1) {
|
|
383
|
+
return true;
|
|
384
|
+
}
|
|
385
|
+
return basicInitiatorTypes.indexOf(entry.initiatorType) >= 0;
|
|
386
|
+
}
|
|
387
|
+
_logResourceTimingEntries(list) {
|
|
388
|
+
for (const entry of list.getEntriesByType('resource')) {
|
|
389
|
+
if (this._shouldInclude(entry)) {
|
|
390
|
+
const payload = this._resourceEntryToNetworkType(entry);
|
|
391
|
+
const options = {
|
|
392
|
+
perfStartOverride: payload.startTime,
|
|
393
|
+
perfStopOverride: payload.startTime + payload.duration
|
|
394
|
+
};
|
|
395
|
+
this._instr
|
|
396
|
+
.startActivity(this._logResourceTimingActivityName)
|
|
397
|
+
.stop(network_request, payload, options);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
|
|
250
403
|
const defaultTraceIdLengthW3 = 32;
|
|
251
404
|
const defaultTraceIdLengthB3 = 16;
|
|
252
405
|
const defaultSpanIdLength = 16;
|
|
@@ -256,6 +409,7 @@ const headerTraceId = 'X-B3-TraceId';
|
|
|
256
409
|
const headerSpanId = 'X-B3-SpanId';
|
|
257
410
|
const headerSampled = 'X-B3-Sampled';
|
|
258
411
|
const headerParentSpanId = 'X-B3-ParentSpanId';
|
|
412
|
+
const headerRequestId = 'X-SFDC-Request-Id';
|
|
259
413
|
const defaultActivityNameForFetch = 'fetch';
|
|
260
414
|
const defaultActivityNameForXhrSend = 'xhr_send';
|
|
261
415
|
class Tracing {
|
|
@@ -349,10 +503,14 @@ class Tracing {
|
|
|
349
503
|
Tracing._global.XMLHttpRequest.prototype.send = Tracing._originalXhrSend;
|
|
350
504
|
Tracing._originalXhrSend = undefined;
|
|
351
505
|
}
|
|
506
|
+
if (Tracing._performanceOfResources) {
|
|
507
|
+
Tracing._performanceOfResources.stop();
|
|
508
|
+
Tracing._performanceOfResources = undefined;
|
|
509
|
+
}
|
|
352
510
|
Tracing._isNetworkInstrumentationEnabled = false;
|
|
353
511
|
}
|
|
354
512
|
}
|
|
355
|
-
_enableNetworkInstrumentation(instr, logErrors, activityName, useTracing, options, tasker) {
|
|
513
|
+
_enableNetworkInstrumentation(instr, logErrors, activityName, useTracing, options, tasker, logResourceTiming, logResourceTimingActivityName) {
|
|
356
514
|
if (typeof Tracing._global.fetch === 'function') {
|
|
357
515
|
this._overrideFetch(instr, logErrors, activityName, useTracing, options, tasker);
|
|
358
516
|
Tracing._isNetworkInstrumentationEnabled = true;
|
|
@@ -361,6 +519,11 @@ class Tracing {
|
|
|
361
519
|
this._overrideXhr(instr, logErrors, activityName, useTracing, options, tasker);
|
|
362
520
|
Tracing._isNetworkInstrumentationEnabled = true;
|
|
363
521
|
}
|
|
522
|
+
if (logResourceTiming) {
|
|
523
|
+
Tracing._performanceOfResources = new PerformanceOfResources(instr, logResourceTimingActivityName, logResourceTiming === true ? 'full' : logResourceTiming);
|
|
524
|
+
Tracing._performanceOfResources.start();
|
|
525
|
+
Tracing._isNetworkInstrumentationEnabled = true;
|
|
526
|
+
}
|
|
364
527
|
}
|
|
365
528
|
static _getTraceHeaders(activity, options, method, url) {
|
|
366
529
|
let traceHeaders = (activity === null || activity === void 0 ? void 0 : activity.getTraceHeaders(options)) || {};
|
|
@@ -384,12 +547,33 @@ class Tracing {
|
|
|
384
547
|
}
|
|
385
548
|
return traceHeaders || {};
|
|
386
549
|
}
|
|
550
|
+
static _extractHeader(headerName, input, init) {
|
|
551
|
+
if ((init === null || init === void 0 ? void 0 : init.headers) instanceof Headers) {
|
|
552
|
+
return init.headers.get(headerName);
|
|
553
|
+
}
|
|
554
|
+
if (Array.isArray(init === null || init === void 0 ? void 0 : init.headers)) {
|
|
555
|
+
const header = init.headers.find((entry) => entry[0] === headerName);
|
|
556
|
+
return header === null || header === void 0 ? void 0 : header[1];
|
|
557
|
+
}
|
|
558
|
+
if (typeof (init === null || init === void 0 ? void 0 : init.headers) === 'object') {
|
|
559
|
+
return init.headers[headerName];
|
|
560
|
+
}
|
|
561
|
+
if (input instanceof Request) {
|
|
562
|
+
return input.headers.get(headerName);
|
|
563
|
+
}
|
|
564
|
+
return undefined;
|
|
565
|
+
}
|
|
387
566
|
_overrideFetch(instr, logErrors, activityName, useTracing, tracingHeadersOptions, tasker) {
|
|
388
567
|
Tracing._originalFetch = Tracing._global.fetch;
|
|
389
568
|
const o11yFetch = async (resource, options, ...restArgs) => {
|
|
569
|
+
var _a;
|
|
390
570
|
let activity;
|
|
571
|
+
let url;
|
|
572
|
+
let method;
|
|
573
|
+
let fetchTime;
|
|
391
574
|
try {
|
|
392
575
|
tasker === null || tasker === void 0 ? void 0 : tasker.add();
|
|
576
|
+
method = options === null || options === void 0 ? void 0 : options.method;
|
|
393
577
|
const ofo = options === null || options === void 0 ? void 0 : options.o11y;
|
|
394
578
|
if (!(ofo === null || ofo === void 0 ? void 0 : ofo.skipInstr)) {
|
|
395
579
|
activity = instr.startActivity(activityName || defaultActivityNameForFetch);
|
|
@@ -407,12 +591,11 @@ class Tracing {
|
|
|
407
591
|
resource = urlObj.toString();
|
|
408
592
|
}
|
|
409
593
|
}
|
|
410
|
-
catch (
|
|
594
|
+
catch (_b) { }
|
|
411
595
|
}
|
|
412
596
|
options === null || options === void 0 ? true : delete options.o11y;
|
|
597
|
+
url = resource === null || resource === void 0 ? void 0 : resource.toString();
|
|
413
598
|
if (useTracing) {
|
|
414
|
-
let method = options === null || options === void 0 ? void 0 : options.method;
|
|
415
|
-
let url = resource === null || resource === void 0 ? void 0 : resource.toString();
|
|
416
599
|
if (resource instanceof Request) {
|
|
417
600
|
if (!method) {
|
|
418
601
|
method = resource.method;
|
|
@@ -427,6 +610,7 @@ class Tracing {
|
|
|
427
610
|
};
|
|
428
611
|
}
|
|
429
612
|
}
|
|
613
|
+
fetchTime = utility.perfNow();
|
|
430
614
|
return await Tracing._originalFetch.call(Tracing._global, resource, options, ...restArgs);
|
|
431
615
|
}
|
|
432
616
|
catch (ex) {
|
|
@@ -441,16 +625,56 @@ class Tracing {
|
|
|
441
625
|
throw ex;
|
|
442
626
|
}
|
|
443
627
|
finally {
|
|
444
|
-
|
|
445
|
-
|
|
628
|
+
try {
|
|
629
|
+
const activityDuration = Tracing._endActivity(activity, url, method);
|
|
630
|
+
if ((_a = Tracing._performanceOfResources) === null || _a === void 0 ? void 0 : _a.isStarted) {
|
|
631
|
+
const requestId = Tracing._extractHeader(headerRequestId, resource, options);
|
|
632
|
+
Tracing._performanceOfResources.addEntry(url, fetchTime, {
|
|
633
|
+
requestId,
|
|
634
|
+
activityDuration
|
|
635
|
+
});
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
finally {
|
|
639
|
+
tasker === null || tasker === void 0 ? void 0 : tasker.done();
|
|
640
|
+
}
|
|
446
641
|
}
|
|
447
642
|
};
|
|
448
643
|
Tracing._global.fetch = o11yFetch;
|
|
449
644
|
}
|
|
645
|
+
static _endActivity(activity, url, method) {
|
|
646
|
+
var _a;
|
|
647
|
+
if (activity) {
|
|
648
|
+
if (activity.getErrorCount() == 0 || ((_a = Tracing._performanceOfResources) === null || _a === void 0 ? void 0 : _a.isStarted)) {
|
|
649
|
+
activity.discard();
|
|
650
|
+
}
|
|
651
|
+
else {
|
|
652
|
+
activity.stop(networkSchema, {
|
|
653
|
+
mtd: method,
|
|
654
|
+
url
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
return activity.getStopPerfTime() - activity.getStartPerfTime();
|
|
658
|
+
}
|
|
659
|
+
return undefined;
|
|
660
|
+
}
|
|
450
661
|
_overrideXhr(instr, logErrors, activityName, useTracing, options, tasker) {
|
|
451
662
|
Tracing._originalXhr = Tracing._global.XMLHttpRequest;
|
|
452
663
|
Tracing._originalXhrOpen = Tracing._originalXhr.prototype.open;
|
|
453
664
|
Tracing._originalXhrSend = Tracing._originalXhr.prototype.send;
|
|
665
|
+
function postProcess(xhr, failedAtInit) {
|
|
666
|
+
var _a;
|
|
667
|
+
if (xhr._o11y) {
|
|
668
|
+
const activityDuration = Tracing._endActivity(xhr._o11y.activity, xhr._o11y.url, xhr._o11y.method);
|
|
669
|
+
if (!failedAtInit && ((_a = Tracing._performanceOfResources) === null || _a === void 0 ? void 0 : _a.isStarted)) {
|
|
670
|
+
const requestId = xhr.getResponseHeader(headerRequestId);
|
|
671
|
+
Tracing._performanceOfResources.addEntry(xhr._o11y.url, xhr._o11y.sendTime, {
|
|
672
|
+
requestId,
|
|
673
|
+
activityDuration
|
|
674
|
+
});
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
}
|
|
454
678
|
Tracing._originalXhr.prototype.open = function (method, url, async, username, password) {
|
|
455
679
|
this._o11y = {
|
|
456
680
|
method,
|
|
@@ -460,9 +684,9 @@ class Tracing {
|
|
|
460
684
|
};
|
|
461
685
|
Tracing._originalXhr.prototype.send = function (...args) {
|
|
462
686
|
let activity;
|
|
687
|
+
const xhr = this;
|
|
463
688
|
try {
|
|
464
689
|
tasker === null || tasker === void 0 ? void 0 : tasker.add();
|
|
465
|
-
const xhr = this;
|
|
466
690
|
xhr._o11y = xhr._o11y || {};
|
|
467
691
|
xhr._o11y.activity = activity = instr.startActivity(activityName || defaultActivityNameForXhrSend);
|
|
468
692
|
if (useTracing) {
|
|
@@ -471,6 +695,7 @@ class Tracing {
|
|
|
471
695
|
xhr.setRequestHeader(entry[0], entry[1]);
|
|
472
696
|
});
|
|
473
697
|
}
|
|
698
|
+
xhr._o11y.sendTime = utility.perfNow();
|
|
474
699
|
Tracing._originalXhrSend.call(this, ...args);
|
|
475
700
|
}
|
|
476
701
|
catch (ex) {
|
|
@@ -482,7 +707,7 @@ class Tracing {
|
|
|
482
707
|
instr.error(ex);
|
|
483
708
|
}
|
|
484
709
|
}
|
|
485
|
-
|
|
710
|
+
postProcess(xhr, true);
|
|
486
711
|
tasker === null || tasker === void 0 ? void 0 : tasker.done();
|
|
487
712
|
throw ex;
|
|
488
713
|
}
|
|
@@ -491,24 +716,27 @@ class Tracing {
|
|
|
491
716
|
construct(target) {
|
|
492
717
|
const newXhr = new target();
|
|
493
718
|
newXhr.addEventListener('load', () => {
|
|
494
|
-
|
|
495
|
-
(_b = (_a = newXhr._o11y) === null || _a === void 0 ? void 0 : _a.activity) === null || _b === void 0 ? void 0 : _b.stop();
|
|
719
|
+
postProcess(newXhr);
|
|
496
720
|
tasker === null || tasker === void 0 ? void 0 : tasker.done();
|
|
497
721
|
});
|
|
498
722
|
newXhr.addEventListener('error', (__err) => {
|
|
499
723
|
var _a;
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
if (activity) {
|
|
724
|
+
try {
|
|
725
|
+
const error = new Error('XHR Network-Level Error');
|
|
503
726
|
if (logErrors) {
|
|
504
|
-
activity.
|
|
727
|
+
const activity = (_a = newXhr._o11y) === null || _a === void 0 ? void 0 : _a.activity;
|
|
728
|
+
if (activity) {
|
|
729
|
+
activity.error(error);
|
|
730
|
+
}
|
|
731
|
+
else {
|
|
732
|
+
instr.error(error);
|
|
733
|
+
}
|
|
505
734
|
}
|
|
506
|
-
|
|
735
|
+
postProcess(newXhr);
|
|
507
736
|
}
|
|
508
|
-
|
|
509
|
-
|
|
737
|
+
finally {
|
|
738
|
+
tasker === null || tasker === void 0 ? void 0 : tasker.done();
|
|
510
739
|
}
|
|
511
|
-
tasker === null || tasker === void 0 ? void 0 : tasker.done();
|
|
512
740
|
});
|
|
513
741
|
newXhr.addEventListener('abort', () => {
|
|
514
742
|
var _a, _b;
|
|
@@ -530,7 +758,7 @@ class Tracing {
|
|
|
530
758
|
if (utility.definedValueOrDefault(tracingOptions.useTasker, true)) {
|
|
531
759
|
tasker = (_a = this._idleDetector) === null || _a === void 0 ? void 0 : _a.declareNotifierTaskMulti('o11y network');
|
|
532
760
|
}
|
|
533
|
-
this._enableNetworkInstrumentation(utility.definedValueOrDefault(tracingOptions.instrumentation, this._instr), utility.definedValueOrDefault(tracingOptions.logErrors, true), tracingOptions.activityName, utility.definedValueOrDefault(tracingOptions.useTracing, true), tracingOptions.tracingHeadersOptions, tasker);
|
|
761
|
+
this._enableNetworkInstrumentation(utility.definedValueOrDefault(tracingOptions.instrumentation, this._instr), utility.definedValueOrDefault(tracingOptions.logErrors, true), tracingOptions.activityName, utility.definedValueOrDefault(tracingOptions.useTracing, true), tracingOptions.tracingHeadersOptions, tasker, utility.definedValueOrDefault(tracingOptions.logResourceTiming, true), utility.definedValueOrDefault(tracingOptions.logResourceTimingActivityName, 'perf-res-timing'));
|
|
534
762
|
}
|
|
535
763
|
}
|
|
536
764
|
resetRequestCounter() {
|
|
@@ -767,6 +995,9 @@ class ActivityImpl {
|
|
|
767
995
|
getStopPerfTime() {
|
|
768
996
|
return this._stopPerfTime;
|
|
769
997
|
}
|
|
998
|
+
getErrorCount() {
|
|
999
|
+
return this._errorCount;
|
|
1000
|
+
}
|
|
770
1001
|
}
|
|
771
1002
|
ActivityImpl._count = 0;
|
|
772
1003
|
|
|
@@ -797,6 +1028,9 @@ class ActivityNoOp {
|
|
|
797
1028
|
getStopPerfTime() {
|
|
798
1029
|
return undefined;
|
|
799
1030
|
}
|
|
1031
|
+
getErrorCount() {
|
|
1032
|
+
return 0;
|
|
1033
|
+
}
|
|
800
1034
|
}
|
|
801
1035
|
const activityNoOp = Object.freeze(new ActivityNoOp());
|
|
802
1036
|
|
|
@@ -1496,6 +1730,9 @@ class RootActivityNoOp {
|
|
|
1496
1730
|
getStopPerfTime() {
|
|
1497
1731
|
return undefined;
|
|
1498
1732
|
}
|
|
1733
|
+
getErrorCount() {
|
|
1734
|
+
return 0;
|
|
1735
|
+
}
|
|
1499
1736
|
}
|
|
1500
1737
|
const rootActivityNoOp = Object.freeze(new RootActivityNoOp());
|
|
1501
1738
|
|
|
@@ -2159,7 +2396,7 @@ class ConsoleCollector {
|
|
|
2159
2396
|
}
|
|
2160
2397
|
}
|
|
2161
2398
|
|
|
2162
|
-
const version = '248.
|
|
2399
|
+
const version = '248.9.0';
|
|
2163
2400
|
|
|
2164
2401
|
const idleDetector = new IdleDetectorImpl({
|
|
2165
2402
|
logThreshold: 300,
|