o11y 240.0.0 → 240.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 +194 -31
- package/dist/modules/o11y/client/client.js.map +1 -1
- package/dist/modules/o11y/client/collectors/core-collector/CoreCollector.d.ts +4 -0
- package/dist/modules/o11y/client/collectors/core-collector/interfaces/LogMessage.d.ts +1 -0
- package/dist/modules/o11y/client/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/client/interfaces/ActivityStopOptions.d.ts +4 -0
- package/dist/modules/o11y/client/interfaces/IdleDetector.d.ts +1 -1
- package/dist/modules/o11y/client/interfaces/IdleDetectorOptions.d.ts +3 -0
- package/dist/modules/o11y/client/interfaces/IdleDetectorReport.d.ts +10 -0
- package/dist/modules/o11y/client/interfaces/LogMeta.d.ts +1 -0
- package/dist/modules/o11y/client/interfaces/index.d.ts +3 -0
- package/dist/modules/o11y/client/library/ActivityImpl.d.ts +7 -4
- package/dist/modules/o11y/client/library/IdleDetectorImpl.d.ts +11 -2
- package/dist/modules/o11y/client/library/NextgenImpl.d.ts +1 -0
- package/dist/modules/o11y/client/library/TimerOverride.d.ts +6 -0
- package/dist/modules/o11y/client/shared/Utility.d.ts +1 -0
- package/dist/modules/o11y/collectors/collectors/core-collector/CoreCollector.d.ts +4 -0
- package/dist/modules/o11y/collectors/collectors/core-collector/interfaces/LogMessage.d.ts +1 -0
- package/dist/modules/o11y/collectors/collectors.js +35 -66
- package/dist/modules/o11y/collectors/collectors.js.map +1 -1
- package/dist/modules/o11y/collectors/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/collectors/interfaces/ActivityStopOptions.d.ts +4 -0
- package/dist/modules/o11y/collectors/interfaces/IdleDetector.d.ts +1 -1
- package/dist/modules/o11y/collectors/interfaces/IdleDetectorOptions.d.ts +3 -0
- package/dist/modules/o11y/collectors/interfaces/IdleDetectorReport.d.ts +10 -0
- package/dist/modules/o11y/collectors/interfaces/LogMeta.d.ts +1 -0
- package/dist/modules/o11y/collectors/interfaces/index.d.ts +3 -0
- package/dist/modules/o11y/collectors/library/ActivityImpl.d.ts +7 -4
- package/dist/modules/o11y/collectors/library/IdleDetectorImpl.d.ts +11 -2
- package/dist/modules/o11y/collectors/library/NextgenImpl.d.ts +1 -0
- package/dist/modules/o11y/collectors/library/TimerOverride.d.ts +6 -0
- package/dist/modules/o11y/collectors/shared/Utility.d.ts +1 -0
- package/dist/modules/o11y/shared/collectors/core-collector/CoreCollector.d.ts +4 -0
- package/dist/modules/o11y/shared/collectors/core-collector/interfaces/LogMessage.d.ts +1 -0
- package/dist/modules/o11y/shared/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/shared/interfaces/ActivityStopOptions.d.ts +4 -0
- package/dist/modules/o11y/shared/interfaces/IdleDetector.d.ts +1 -1
- package/dist/modules/o11y/shared/interfaces/IdleDetectorOptions.d.ts +3 -0
- package/dist/modules/o11y/shared/interfaces/IdleDetectorReport.d.ts +10 -0
- package/dist/modules/o11y/shared/interfaces/LogMeta.d.ts +1 -0
- package/dist/modules/o11y/shared/interfaces/index.d.ts +3 -0
- package/dist/modules/o11y/shared/library/ActivityImpl.d.ts +7 -4
- package/dist/modules/o11y/shared/library/IdleDetectorImpl.d.ts +11 -2
- package/dist/modules/o11y/shared/library/NextgenImpl.d.ts +1 -0
- package/dist/modules/o11y/shared/library/TimerOverride.d.ts +6 -0
- package/dist/modules/o11y/shared/shared/Utility.d.ts +1 -0
- package/dist/modules/o11y/shared/shared.js +6 -0
- package/dist/modules/o11y/shared/shared.js.map +1 -1
- package/dist/modules/o11y/web_vitals/collectors/core-collector/CoreCollector.d.ts +4 -0
- package/dist/modules/o11y/web_vitals/collectors/core-collector/interfaces/LogMessage.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/web_vitals/interfaces/ActivityStopOptions.d.ts +4 -0
- package/dist/modules/o11y/web_vitals/interfaces/IdleDetector.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/interfaces/IdleDetectorOptions.d.ts +3 -0
- package/dist/modules/o11y/web_vitals/interfaces/IdleDetectorReport.d.ts +10 -0
- package/dist/modules/o11y/web_vitals/interfaces/LogMeta.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/interfaces/index.d.ts +3 -0
- package/dist/modules/o11y/web_vitals/library/ActivityImpl.d.ts +7 -4
- package/dist/modules/o11y/web_vitals/library/IdleDetectorImpl.d.ts +11 -2
- package/dist/modules/o11y/web_vitals/library/NextgenImpl.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/library/TimerOverride.d.ts +6 -0
- package/dist/modules/o11y/web_vitals/shared/Utility.d.ts +1 -0
- package/package.json +3 -21
|
@@ -220,6 +220,14 @@ class Tracing {
|
|
|
220
220
|
Tracing._global = utility.getGlobal();
|
|
221
221
|
Tracing._isNetworkInstrumentationEnabled = false;
|
|
222
222
|
|
|
223
|
+
var TimerOverride;
|
|
224
|
+
(function (TimerOverride) {
|
|
225
|
+
TimerOverride[TimerOverride["none"] = 0] = "none";
|
|
226
|
+
TimerOverride[TimerOverride["start"] = 1] = "start";
|
|
227
|
+
TimerOverride[TimerOverride["stop"] = 2] = "stop";
|
|
228
|
+
TimerOverride[TimerOverride["both"] = 3] = "both";
|
|
229
|
+
})(TimerOverride || (TimerOverride = {}));
|
|
230
|
+
|
|
223
231
|
const timedout = 'timedout';
|
|
224
232
|
const terminated = 'terminated';
|
|
225
233
|
const discarded = 'discarded';
|
|
@@ -236,6 +244,7 @@ class ActivityImpl {
|
|
|
236
244
|
this._onError = _onError;
|
|
237
245
|
this._isSampled = _isSampled;
|
|
238
246
|
this._errorCount = 0;
|
|
247
|
+
this._timerOverridden = TimerOverride.none;
|
|
239
248
|
const { tsNow, perfNow } = utility.time();
|
|
240
249
|
ActivityImpl._count += 1;
|
|
241
250
|
this._id = id || utility.generateUniqueId();
|
|
@@ -284,10 +293,51 @@ class ActivityImpl {
|
|
|
284
293
|
this._onError(error, this._getDetail(userSchemaOrText, userData));
|
|
285
294
|
});
|
|
286
295
|
}
|
|
287
|
-
stop(userSchemaOrText, userData) {
|
|
288
|
-
this._safety.tryCatch(() =>
|
|
296
|
+
stop(userSchemaOrText, userData, options) {
|
|
297
|
+
this._safety.tryCatch(() => {
|
|
298
|
+
utility.requireArgumentIfDefined(userSchemaOrText, 'userSchemaOrText', [
|
|
299
|
+
'object',
|
|
300
|
+
'string'
|
|
301
|
+
]);
|
|
302
|
+
utility.requireArgumentIfDefined(userData, 'userData', 'object');
|
|
303
|
+
if (options) {
|
|
304
|
+
const perfStart = options.perfStartOverride;
|
|
305
|
+
const isStartTimeDefined = utility.requireArgumentIfDefined(perfStart, 'options.perfStartOverride', 'number');
|
|
306
|
+
const perfStop = options.perfStopOverride;
|
|
307
|
+
const isStopTimeDefined = utility.requireArgumentIfDefined(perfStop, 'options.perfStopOverride', 'number');
|
|
308
|
+
if (isStartTimeDefined && perfStart < 0) {
|
|
309
|
+
throw new Error('perfStartOverride, if defined, must be >= 0');
|
|
310
|
+
}
|
|
311
|
+
if (isStopTimeDefined &&
|
|
312
|
+
(perfStop < 0 ||
|
|
313
|
+
perfStop < (isStartTimeDefined ? perfStart : this._startPerfTime))) {
|
|
314
|
+
throw new Error('perfStopOverride, if defined, must be >= 0 and >= startTime');
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
this._stopInternal(userSchemaOrText, userData, options);
|
|
318
|
+
});
|
|
289
319
|
}
|
|
290
|
-
|
|
320
|
+
_overrideTimer(perfStartTime, perfStopTime) {
|
|
321
|
+
if (perfStartTime !== undefined) {
|
|
322
|
+
this._startTimestamp = Math.round(this._startTimestamp - (this._startPerfTime - perfStartTime));
|
|
323
|
+
this._startPerfTime = perfStartTime;
|
|
324
|
+
this._setTimerOverride(TimerOverride.start);
|
|
325
|
+
}
|
|
326
|
+
if (perfStopTime !== undefined) {
|
|
327
|
+
this._stopPerfTime = perfStopTime;
|
|
328
|
+
this._setTimerOverride(TimerOverride.stop);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
_setTimerOverride(value) {
|
|
332
|
+
if (this._timerOverridden === TimerOverride.both ||
|
|
333
|
+
this._timerOverridden === value ||
|
|
334
|
+
value === TimerOverride.none) {
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
this._timerOverridden =
|
|
338
|
+
this._timerOverridden === TimerOverride.none ? value : TimerOverride.both;
|
|
339
|
+
}
|
|
340
|
+
_stopInternal(userSchemaOrText, userData, options) {
|
|
291
341
|
const stopPerfTime = utility.perfNow();
|
|
292
342
|
if (this._usePerf) {
|
|
293
343
|
try {
|
|
@@ -306,7 +356,14 @@ class ActivityImpl {
|
|
|
306
356
|
if (this.isStopped) {
|
|
307
357
|
return;
|
|
308
358
|
}
|
|
309
|
-
|
|
359
|
+
if (options) {
|
|
360
|
+
this._overrideTimer(options.perfStartOverride, options.perfStopOverride);
|
|
361
|
+
}
|
|
362
|
+
this._stopPerfTime =
|
|
363
|
+
this._timerOverridden === TimerOverride.none ||
|
|
364
|
+
this._timerOverridden === TimerOverride.start
|
|
365
|
+
? stopPerfTime
|
|
366
|
+
: this._stopPerfTime;
|
|
310
367
|
const activityDetail = this._getDetail(userSchemaOrText, userData);
|
|
311
368
|
this._onStopped(activityDetail);
|
|
312
369
|
}
|
|
@@ -340,7 +397,8 @@ class ActivityImpl {
|
|
|
340
397
|
startPerfTime: this._startPerfTime,
|
|
341
398
|
stopPerfTime: this._stopPerfTime,
|
|
342
399
|
errorCount: this._errorCount,
|
|
343
|
-
isSampled: this.getIsSampled()
|
|
400
|
+
isSampled: this.getIsSampled(),
|
|
401
|
+
timerOverridden: this._timerOverridden
|
|
344
402
|
};
|
|
345
403
|
}
|
|
346
404
|
getTraceHeaders(options) {
|
|
@@ -366,6 +424,9 @@ const activity={namespace:"sf.instrumentation",name:"Activity",pbjsSchema:{"nest
|
|
|
366
424
|
const error={namespace:"sf.instrumentation",name:"Error",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"Error":{"reserved":[[5,5],[7,7]],"fields":{"activityId":{"options":{},"id":6,"type":"string"},"stack":{"options":{},"id":3,"type":"string"},"name":{"options":{},"id":1,"type":"string"},"message":{"options":{"(meta.max_length)":200},"id":2,"type":"string"},"userPayload":{"options":{},"id":4,"type":"Payload"}}},"Payload":{"fields":{"payload":{"options":{},"id":2,"type":"bytes"},
|
|
367
425
|
"schemaName":{"options":{},"id":1,"type":"string"}}}}}}}}}};
|
|
368
426
|
|
|
427
|
+
const idle_detector_report={namespace:"sf.instrumentation",name:"IdleDetectorReport",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"IdleDetectorReport":{"options":{"(meta.msg.desc)":"This is used by the Idle Detector in o11y"},"fields":{"listenerCount":{"options":{},"id":3,"type":"uint32"},"busyTasks":{"options":{},"rule":"repeated","id":5,"type":"string"},"busyDurations":{"options":{},"rule":"repeated","id":6,"type":"double"},"pollableCount":{"options":{},"id":4,"type":"uint32"},
|
|
428
|
+
"pollCounts":{"options":{},"rule":"repeated","id":8,"type":"double"},"logThreshold":{"options":{},"id":2,"type":"double"},"maxDuration":{"options":{},"id":1,"type":"double"},"pollables":{"options":{},"rule":"repeated","id":7,"type":"string"}}}}}}}}}};
|
|
429
|
+
|
|
369
430
|
const instrumented_event={namespace:"sf.instrumentation",name:"InstrumentedEvent",pbjsSchema:{"nested":{"sf":{"nested":{"instrumentation":{"nested":{"MouseEvent":{"fields":{"cancelable":{"options":{},"id":5,"type":"bool"},"ctrlKey":{"options":{},"id":9,"type":"bool"},"type":{"options":{},"id":25,"type":"string"},"button":{"options":{},"id":3,"type":"uint32"},"offsetX":{"options":{},"id":17,"type":"uint32"},"eventPhase":{"options":{},"id":12,"type":"uint32"},"shiftKey":{"options":{},"id":23,
|
|
370
431
|
"type":"bool"},"offsetY":{"options":{},"id":18,"type":"uint32"},"composed":{"options":{},"id":8,"type":"bool"},"altKey":{"options":{},"id":1,"type":"bool"},"isTrusted":{"options":{},"id":13,"type":"bool"},"buttons":{"options":{},"id":4,"type":"uint32"},"movementY":{"options":{},"id":16,"type":"uint32"},"clientY":{"options":{},"id":7,"type":"uint32"},"clientX":{"options":{},"id":6,"type":"uint32"},"movementX":{"options":{},"id":15,"type":"uint32"},"defaultPrevented":{"options":{},"id":10,"type":"bool"},
|
|
371
432
|
"metaKey":{"options":{},"id":14,"type":"bool"},"timeStamp":{"options":{},"id":24,"type":"double"},"bubbles":{"options":{},"id":2,"type":"bool"},"detail":{"options":{},"id":11,"type":"int64"},"pageY":{"options":{},"id":20,"type":"uint32"},"pageX":{"options":{},"id":19,"type":"uint32"},"screenX":{"options":{},"id":21,"type":"uint32"},"screenY":{"options":{},"id":22,"type":"uint32"}}},"InstrumentedEvent":{"oneofs":{"event":{"oneof":["mouseEvent"]}},"reserved":[[4,4],"xpath",[6,6],[8,8]],"fields":{"mouseEvent":{"options":{},
|
|
@@ -539,9 +600,9 @@ class LogValidator {
|
|
|
539
600
|
if (fieldDataValue.length > maxItemCountAppLimit) {
|
|
540
601
|
errorCode = 7;
|
|
541
602
|
}
|
|
542
|
-
|
|
543
|
-
this.matchFieldTypes(errorInfos, [...fieldNames,
|
|
544
|
-
}
|
|
603
|
+
fieldDataValue.forEach((value, index) => {
|
|
604
|
+
this.matchFieldTypes(errorInfos, [...fieldNames, index.toString()], value, protobufType, descriptor, schemaId, key);
|
|
605
|
+
});
|
|
545
606
|
}
|
|
546
607
|
else {
|
|
547
608
|
errorCode = 1;
|
|
@@ -1406,6 +1467,7 @@ class NextgenImpl {
|
|
|
1406
1467
|
constructor() {
|
|
1407
1468
|
this._logCollectors = new Set();
|
|
1408
1469
|
this._instruments = new Map();
|
|
1470
|
+
this._seqBySchema = new Map();
|
|
1409
1471
|
this._sequence = 0;
|
|
1410
1472
|
this._forceDisabledLogCollectors = new Set();
|
|
1411
1473
|
this._logCollectorFailures = new Map();
|
|
@@ -1479,18 +1541,20 @@ class NextgenImpl {
|
|
|
1479
1541
|
}
|
|
1480
1542
|
addLog(loggerName, schema, data, timestamp, rootId, pagePayload, appPayload) {
|
|
1481
1543
|
this._sequence += 1;
|
|
1482
|
-
const
|
|
1483
|
-
|
|
1484
|
-
|
|
1544
|
+
const schemaId = schemaUtil.getSchemaId(schema);
|
|
1545
|
+
let schemaSequence = this._seqBySchema.get(schemaId) || 0;
|
|
1546
|
+
schemaSequence += 1;
|
|
1547
|
+
this._seqBySchema.set(schemaId, schemaSequence);
|
|
1485
1548
|
const logMeta = {
|
|
1486
1549
|
timestamp,
|
|
1487
1550
|
rootId,
|
|
1488
|
-
sequence,
|
|
1551
|
+
sequence: this._sequence,
|
|
1552
|
+
schemaSequence,
|
|
1489
1553
|
loggerName,
|
|
1490
1554
|
pagePayload: pagePayload ? utility.clone(pagePayload) : undefined,
|
|
1491
1555
|
appPayload: appPayload ? utility.clone(appPayload) : undefined,
|
|
1492
|
-
loggerAppName,
|
|
1493
|
-
connectionType
|
|
1556
|
+
loggerAppName: this.appName,
|
|
1557
|
+
connectionType: utility.getConnectionType()
|
|
1494
1558
|
};
|
|
1495
1559
|
if (this._isBufferingEnabled) {
|
|
1496
1560
|
this._buffer.push({ schema, data: utility.clone(data), logMeta });
|
|
@@ -1617,7 +1681,7 @@ class Index {
|
|
|
1617
1681
|
return this._nextgen;
|
|
1618
1682
|
}
|
|
1619
1683
|
registerInstrumentedApp(name, options) {
|
|
1620
|
-
if (options
|
|
1684
|
+
if (!options || options.isProduction !== false) {
|
|
1621
1685
|
utility.markProduction();
|
|
1622
1686
|
}
|
|
1623
1687
|
const retVal = this._lazyNextGen.registerApp(name, options);
|
|
@@ -1669,19 +1733,35 @@ class TaskerImpl {
|
|
|
1669
1733
|
}
|
|
1670
1734
|
}
|
|
1671
1735
|
|
|
1736
|
+
const defaultLogThreshold = 300;
|
|
1672
1737
|
class IdleDetectorImpl {
|
|
1673
|
-
constructor() {
|
|
1738
|
+
constructor(options) {
|
|
1674
1739
|
this._instr = getInstrumentation('IdleDetector');
|
|
1675
|
-
this._taskers = new
|
|
1740
|
+
this._taskers = new Map();
|
|
1676
1741
|
this._listeners = new Set();
|
|
1677
1742
|
this._busyCheckers = new Map();
|
|
1743
|
+
this._logThreshold = defaultLogThreshold;
|
|
1744
|
+
this._endedTasks = new Array();
|
|
1745
|
+
this._pollableReport = new Array();
|
|
1678
1746
|
this._timerCheckQueued = 0;
|
|
1747
|
+
if (utility.requireArgumentIfDefined(options === null || options === void 0 ? void 0 : options.logThreshold, 'options.logThreshold', 'number')) {
|
|
1748
|
+
this._logThreshold = options.logThreshold;
|
|
1749
|
+
}
|
|
1679
1750
|
}
|
|
1680
1751
|
requestIdleDetectedCallback(callback) {
|
|
1681
1752
|
utility.requireArgument(callback, 'callback', 'function');
|
|
1753
|
+
if (this._listeners.size === 0) {
|
|
1754
|
+
this._firstCallbackTime = utility.time().perfNow;
|
|
1755
|
+
}
|
|
1682
1756
|
this._listeners.add(callback);
|
|
1683
1757
|
this.checkIfLoaded();
|
|
1684
1758
|
}
|
|
1759
|
+
reportTaskEnded(tasker) {
|
|
1760
|
+
if (this._listeners.size) {
|
|
1761
|
+
const snapshot = Object.assign({}, this._taskers.get(tasker));
|
|
1762
|
+
this._endedTasks.push(snapshot);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1685
1765
|
declareNotifierTaskSingle(name) {
|
|
1686
1766
|
utility.requireArgument(name, 'name', 'string');
|
|
1687
1767
|
const tasker = this.addTasker(name, 1);
|
|
@@ -1705,7 +1785,22 @@ class IdleDetectorImpl {
|
|
|
1705
1785
|
throw new Error('existingBusyCount accepts only non-negative integers');
|
|
1706
1786
|
}
|
|
1707
1787
|
}
|
|
1708
|
-
|
|
1788
|
+
const tasker = this.addTasker(name, existingBusyCount);
|
|
1789
|
+
const retVal = {
|
|
1790
|
+
get isBusy() {
|
|
1791
|
+
return tasker.isBusy;
|
|
1792
|
+
},
|
|
1793
|
+
add: () => {
|
|
1794
|
+
if (!tasker.isBusy) {
|
|
1795
|
+
const meta = this._taskers.get(tasker);
|
|
1796
|
+
meta.start = utility.time().perfNow;
|
|
1797
|
+
meta.end = undefined;
|
|
1798
|
+
}
|
|
1799
|
+
tasker.add();
|
|
1800
|
+
},
|
|
1801
|
+
done: tasker.done.bind(tasker)
|
|
1802
|
+
};
|
|
1803
|
+
return retVal;
|
|
1709
1804
|
}
|
|
1710
1805
|
declarePollableTaskMulti(name, isBusyChecker) {
|
|
1711
1806
|
utility.requireArgument(name, 'name', 'string');
|
|
@@ -1714,26 +1809,37 @@ class IdleDetectorImpl {
|
|
|
1714
1809
|
}
|
|
1715
1810
|
addTasker(name, existingBusyCount) {
|
|
1716
1811
|
const tasker = new TaskerImpl(name, existingBusyCount, () => {
|
|
1812
|
+
this._taskers.get(tasker).end = utility.time().perfNow;
|
|
1813
|
+
this.reportTaskEnded(tasker);
|
|
1717
1814
|
this.checkIfLoaded();
|
|
1718
1815
|
}, () => {
|
|
1719
|
-
|
|
1816
|
+
this._instr.error(`Overdone: ${tasker.name}`);
|
|
1817
|
+
utility.noProdThrow(`Tasker '${tasker.name}' is done too many times.`);
|
|
1818
|
+
});
|
|
1819
|
+
this._taskers.set(tasker, {
|
|
1820
|
+
name,
|
|
1821
|
+
start: existingBusyCount > 0 ? utility.time().perfNow : undefined,
|
|
1822
|
+
end: undefined
|
|
1720
1823
|
});
|
|
1721
|
-
this._taskers.add(tasker);
|
|
1722
1824
|
return tasker;
|
|
1723
1825
|
}
|
|
1724
1826
|
areAllNotifiersIdle() {
|
|
1725
|
-
return !Array.from(this._taskers.
|
|
1827
|
+
return !Array.from(this._taskers.keys()).some((t) => t.isBusy);
|
|
1726
1828
|
}
|
|
1727
|
-
|
|
1728
|
-
|
|
1829
|
+
getFirstBusyPollable() {
|
|
1830
|
+
const entry = Array.from(this._busyCheckers).find((entry) => {
|
|
1831
|
+
const isBusyChecker = entry[0];
|
|
1832
|
+
const name = entry[1];
|
|
1729
1833
|
try {
|
|
1730
|
-
return
|
|
1834
|
+
return isBusyChecker();
|
|
1731
1835
|
}
|
|
1732
1836
|
catch (e) {
|
|
1733
|
-
this._instr.error(e, `BusyChecker
|
|
1837
|
+
this._instr.error(e, `BusyChecker ${name}`);
|
|
1838
|
+
utility.noProdThrow(e);
|
|
1734
1839
|
return false;
|
|
1735
1840
|
}
|
|
1736
1841
|
});
|
|
1842
|
+
return entry ? entry[1] : undefined;
|
|
1737
1843
|
}
|
|
1738
1844
|
checkIfLoaded() {
|
|
1739
1845
|
if (!this._listeners.size) {
|
|
@@ -1753,29 +1859,84 @@ class IdleDetectorImpl {
|
|
|
1753
1859
|
doubleCheck() {
|
|
1754
1860
|
this._timerCheckQueued = 0;
|
|
1755
1861
|
if (this.areAllNotifiersIdle()) {
|
|
1756
|
-
|
|
1862
|
+
const pollableName = this.getFirstBusyPollable();
|
|
1863
|
+
if (pollableName !== undefined) {
|
|
1864
|
+
this.addToPollableReport(pollableName);
|
|
1757
1865
|
this._timerCheckQueued = window.setTimeout(() => {
|
|
1758
1866
|
this.doubleCheck();
|
|
1759
1867
|
}, 15);
|
|
1760
1868
|
}
|
|
1761
1869
|
else {
|
|
1870
|
+
const maxDuration = utility.time().perfNow - this._firstCallbackTime;
|
|
1762
1871
|
const listeners = Array.from(this._listeners.values());
|
|
1763
1872
|
this._listeners.clear();
|
|
1764
|
-
this.
|
|
1873
|
+
this._firstCallbackTime = undefined;
|
|
1874
|
+
const endedTasks = this._endedTasks.splice(0);
|
|
1875
|
+
const pollableReport = this._pollableReport.splice(0);
|
|
1876
|
+
this.notify(listeners, maxDuration, endedTasks, pollableReport);
|
|
1765
1877
|
}
|
|
1766
1878
|
}
|
|
1767
1879
|
}
|
|
1768
|
-
|
|
1769
|
-
const
|
|
1880
|
+
addToPollableReport(name) {
|
|
1881
|
+
const lastEntry = this._pollableReport.length
|
|
1882
|
+
? this._pollableReport[this._pollableReport.length - 1]
|
|
1883
|
+
: undefined;
|
|
1884
|
+
if ((lastEntry === null || lastEntry === void 0 ? void 0 : lastEntry.name) === name) {
|
|
1885
|
+
lastEntry.count += 1;
|
|
1886
|
+
}
|
|
1887
|
+
else {
|
|
1888
|
+
this._pollableReport.push({
|
|
1889
|
+
name,
|
|
1890
|
+
count: 1
|
|
1891
|
+
});
|
|
1892
|
+
}
|
|
1893
|
+
}
|
|
1894
|
+
notify(listeners, maxDuration, taskReport, pollableReport) {
|
|
1895
|
+
if (maxDuration >= this._logThreshold) {
|
|
1896
|
+
const logData = this._getReport(maxDuration, listeners.length, taskReport, pollableReport);
|
|
1897
|
+
this._instr.log(idle_detector_report, logData);
|
|
1898
|
+
}
|
|
1899
|
+
const tsNow = utility.time().tsNow;
|
|
1770
1900
|
for (const [index, listener] of listeners.entries()) {
|
|
1771
1901
|
try {
|
|
1772
|
-
listener(
|
|
1902
|
+
listener(tsNow);
|
|
1773
1903
|
}
|
|
1774
1904
|
catch (e) {
|
|
1775
1905
|
this._instr.error(e, `Listener #${index}`);
|
|
1906
|
+
utility.noProdThrow(e);
|
|
1776
1907
|
}
|
|
1777
1908
|
}
|
|
1778
1909
|
}
|
|
1910
|
+
getReport() {
|
|
1911
|
+
const perfNow = utility.time().perfNow;
|
|
1912
|
+
const maxDuration = this._firstCallbackTime > 0 ? perfNow - this._firstCallbackTime : undefined;
|
|
1913
|
+
const onGoingTasks = Array.from(this._taskers.entries())
|
|
1914
|
+
.filter((e) => e[0].isBusy)
|
|
1915
|
+
.map((e) => ({
|
|
1916
|
+
name: e[1].name,
|
|
1917
|
+
start: e[1].start,
|
|
1918
|
+
end: perfNow
|
|
1919
|
+
}));
|
|
1920
|
+
return this._getReport(maxDuration, this._listeners.size, this._endedTasks.concat(onGoingTasks), this._pollableReport);
|
|
1921
|
+
}
|
|
1922
|
+
_getReport(maxDuration, listenerCount, taskReport, pollableReport) {
|
|
1923
|
+
const sortedTaskers = taskReport
|
|
1924
|
+
.map((t) => ({
|
|
1925
|
+
name: t.name,
|
|
1926
|
+
duration: t.end - t.start
|
|
1927
|
+
}))
|
|
1928
|
+
.sort((a, b) => b.duration - a.duration);
|
|
1929
|
+
return {
|
|
1930
|
+
logThreshold: this._logThreshold,
|
|
1931
|
+
maxDuration,
|
|
1932
|
+
listenerCount,
|
|
1933
|
+
pollableCount: this._busyCheckers.size,
|
|
1934
|
+
busyTasks: sortedTaskers.map((t) => t.name),
|
|
1935
|
+
busyDurations: sortedTaskers.map((t) => t.duration),
|
|
1936
|
+
pollables: pollableReport.map((p) => p.name),
|
|
1937
|
+
pollCounts: pollableReport.map((p) => p.count)
|
|
1938
|
+
};
|
|
1939
|
+
}
|
|
1779
1940
|
}
|
|
1780
1941
|
|
|
1781
1942
|
const bgColorMap = {
|
|
@@ -1816,7 +1977,9 @@ class ConsoleCollector {
|
|
|
1816
1977
|
}
|
|
1817
1978
|
}
|
|
1818
1979
|
|
|
1819
|
-
const idleDetector = new IdleDetectorImpl(
|
|
1980
|
+
const idleDetector = new IdleDetectorImpl({
|
|
1981
|
+
logThreshold: 300
|
|
1982
|
+
});
|
|
1820
1983
|
|
|
1821
1984
|
export { ConsoleCollector, getInstrumentation, idleDetector, registerInstrumentedApp, time };
|
|
1822
1985
|
//# sourceMappingURL=client.js.map
|