o11y 248.53.0 → 250.1.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 +136 -27
- package/dist/modules/o11y/client/client.js.map +1 -1
- package/dist/modules/o11y/client/interfaces/ActivityApiOptions.d.ts +4 -0
- package/dist/modules/o11y/client/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/client/interfaces/ActivityStartApiOptions.d.ts +4 -0
- package/dist/modules/o11y/client/interfaces/ActivityStartOptions.d.ts +3 -0
- package/dist/modules/o11y/client/interfaces/Instrumentation.d.ts +2 -1
- package/dist/modules/o11y/client/interfaces/InstrumentedAppMethods.d.ts +2 -1
- package/dist/modules/o11y/client/interfaces/index.d.ts +2 -0
- package/dist/modules/o11y/client/interfaces-private/ActivityData.d.ts +2 -0
- package/dist/modules/o11y/client/library/ActivityImpl.d.ts +2 -1
- package/dist/modules/o11y/client/library/AppInstrumentationImpl.d.ts +5 -2
- package/dist/modules/o11y/client/library/InstrumentationImpl.d.ts +3 -1
- package/dist/modules/o11y/client/library/NextgenImpl.d.ts +2 -0
- package/dist/modules/o11y/client/library/PerformanceObservability.d.ts +1 -1
- package/dist/modules/o11y/client/library/RootActivityHistoryImpl.d.ts +12 -0
- package/dist/modules/o11y/client/library/RootActivityImpl.d.ts +1 -1
- package/dist/modules/o11y/client/library/Tracing.d.ts +1 -0
- package/dist/modules/o11y/client/shared/Utility.d.ts +1 -0
- package/dist/modules/o11y/client/types/RootActivityHistoryEntry.d.ts +7 -0
- package/dist/modules/o11y/client/version.d.ts +1 -1
- package/dist/modules/o11y/collectors/interfaces/ActivityApiOptions.d.ts +4 -0
- package/dist/modules/o11y/collectors/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/collectors/interfaces/ActivityStartApiOptions.d.ts +4 -0
- package/dist/modules/o11y/collectors/interfaces/ActivityStartOptions.d.ts +3 -0
- package/dist/modules/o11y/collectors/interfaces/Instrumentation.d.ts +2 -1
- package/dist/modules/o11y/collectors/interfaces/InstrumentedAppMethods.d.ts +2 -1
- package/dist/modules/o11y/collectors/interfaces/index.d.ts +2 -0
- package/dist/modules/o11y/collectors/interfaces-private/ActivityData.d.ts +2 -0
- package/dist/modules/o11y/collectors/library/ActivityImpl.d.ts +2 -1
- package/dist/modules/o11y/collectors/library/AppInstrumentationImpl.d.ts +5 -2
- package/dist/modules/o11y/collectors/library/InstrumentationImpl.d.ts +3 -1
- package/dist/modules/o11y/collectors/library/NextgenImpl.d.ts +2 -0
- package/dist/modules/o11y/collectors/library/PerformanceObservability.d.ts +1 -1
- package/dist/modules/o11y/collectors/library/RootActivityHistoryImpl.d.ts +12 -0
- package/dist/modules/o11y/collectors/library/RootActivityImpl.d.ts +1 -1
- package/dist/modules/o11y/collectors/library/Tracing.d.ts +1 -0
- package/dist/modules/o11y/collectors/shared/Utility.d.ts +1 -0
- package/dist/modules/o11y/collectors/types/RootActivityHistoryEntry.d.ts +7 -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/ActivityApiOptions.d.ts +4 -0
- package/dist/modules/o11y/core_envelope/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/core_envelope/interfaces/ActivityStartApiOptions.d.ts +4 -0
- package/dist/modules/o11y/core_envelope/interfaces/ActivityStartOptions.d.ts +3 -0
- package/dist/modules/o11y/core_envelope/interfaces/Instrumentation.d.ts +2 -1
- package/dist/modules/o11y/core_envelope/interfaces/InstrumentedAppMethods.d.ts +2 -1
- package/dist/modules/o11y/core_envelope/interfaces/index.d.ts +2 -0
- package/dist/modules/o11y/core_envelope/interfaces-private/ActivityData.d.ts +2 -0
- package/dist/modules/o11y/core_envelope/library/ActivityImpl.d.ts +2 -1
- package/dist/modules/o11y/core_envelope/library/AppInstrumentationImpl.d.ts +5 -2
- package/dist/modules/o11y/core_envelope/library/InstrumentationImpl.d.ts +3 -1
- package/dist/modules/o11y/core_envelope/library/NextgenImpl.d.ts +2 -0
- package/dist/modules/o11y/core_envelope/library/PerformanceObservability.d.ts +1 -1
- package/dist/modules/o11y/core_envelope/library/RootActivityHistoryImpl.d.ts +12 -0
- package/dist/modules/o11y/core_envelope/library/RootActivityImpl.d.ts +1 -1
- package/dist/modules/o11y/core_envelope/library/Tracing.d.ts +1 -0
- package/dist/modules/o11y/core_envelope/shared/Utility.d.ts +1 -0
- package/dist/modules/o11y/core_envelope/types/RootActivityHistoryEntry.d.ts +7 -0
- package/dist/modules/o11y/core_envelope/version.d.ts +1 -1
- package/dist/modules/o11y/shared/interfaces/ActivityApiOptions.d.ts +4 -0
- package/dist/modules/o11y/shared/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/shared/interfaces/ActivityStartApiOptions.d.ts +4 -0
- package/dist/modules/o11y/shared/interfaces/ActivityStartOptions.d.ts +3 -0
- package/dist/modules/o11y/shared/interfaces/Instrumentation.d.ts +2 -1
- package/dist/modules/o11y/shared/interfaces/InstrumentedAppMethods.d.ts +2 -1
- package/dist/modules/o11y/shared/interfaces/index.d.ts +2 -0
- package/dist/modules/o11y/shared/interfaces-private/ActivityData.d.ts +2 -0
- package/dist/modules/o11y/shared/library/ActivityImpl.d.ts +2 -1
- package/dist/modules/o11y/shared/library/AppInstrumentationImpl.d.ts +5 -2
- package/dist/modules/o11y/shared/library/InstrumentationImpl.d.ts +3 -1
- package/dist/modules/o11y/shared/library/NextgenImpl.d.ts +2 -0
- package/dist/modules/o11y/shared/library/PerformanceObservability.d.ts +1 -1
- package/dist/modules/o11y/shared/library/RootActivityHistoryImpl.d.ts +12 -0
- package/dist/modules/o11y/shared/library/RootActivityImpl.d.ts +1 -1
- package/dist/modules/o11y/shared/library/Tracing.d.ts +1 -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/shared/types/RootActivityHistoryEntry.d.ts +7 -0
- package/dist/modules/o11y/shared/version.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/interfaces/ActivityApiOptions.d.ts +4 -0
- package/dist/modules/o11y/simple_collector/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/simple_collector/interfaces/ActivityStartApiOptions.d.ts +4 -0
- package/dist/modules/o11y/simple_collector/interfaces/ActivityStartOptions.d.ts +3 -0
- package/dist/modules/o11y/simple_collector/interfaces/Instrumentation.d.ts +2 -1
- package/dist/modules/o11y/simple_collector/interfaces/InstrumentedAppMethods.d.ts +2 -1
- package/dist/modules/o11y/simple_collector/interfaces/index.d.ts +2 -0
- package/dist/modules/o11y/simple_collector/interfaces-private/ActivityData.d.ts +2 -0
- package/dist/modules/o11y/simple_collector/library/ActivityImpl.d.ts +2 -1
- package/dist/modules/o11y/simple_collector/library/AppInstrumentationImpl.d.ts +5 -2
- package/dist/modules/o11y/simple_collector/library/InstrumentationImpl.d.ts +3 -1
- package/dist/modules/o11y/simple_collector/library/NextgenImpl.d.ts +2 -0
- package/dist/modules/o11y/simple_collector/library/PerformanceObservability.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/library/RootActivityHistoryImpl.d.ts +12 -0
- package/dist/modules/o11y/simple_collector/library/RootActivityImpl.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/library/Tracing.d.ts +1 -0
- package/dist/modules/o11y/simple_collector/shared/Utility.d.ts +1 -0
- package/dist/modules/o11y/simple_collector/types/RootActivityHistoryEntry.d.ts +7 -0
- package/dist/modules/o11y/simple_collector/version.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/interfaces/ActivityApiOptions.d.ts +4 -0
- package/dist/modules/o11y/web_vitals/interfaces/ActivityDetail.d.ts +2 -0
- package/dist/modules/o11y/web_vitals/interfaces/ActivityStartApiOptions.d.ts +4 -0
- package/dist/modules/o11y/web_vitals/interfaces/ActivityStartOptions.d.ts +3 -0
- package/dist/modules/o11y/web_vitals/interfaces/Instrumentation.d.ts +2 -1
- package/dist/modules/o11y/web_vitals/interfaces/InstrumentedAppMethods.d.ts +2 -1
- package/dist/modules/o11y/web_vitals/interfaces/index.d.ts +2 -0
- package/dist/modules/o11y/web_vitals/interfaces-private/ActivityData.d.ts +2 -0
- package/dist/modules/o11y/web_vitals/library/ActivityImpl.d.ts +2 -1
- package/dist/modules/o11y/web_vitals/library/AppInstrumentationImpl.d.ts +5 -2
- package/dist/modules/o11y/web_vitals/library/InstrumentationImpl.d.ts +3 -1
- package/dist/modules/o11y/web_vitals/library/NextgenImpl.d.ts +2 -0
- package/dist/modules/o11y/web_vitals/library/PerformanceObservability.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/library/RootActivityHistoryImpl.d.ts +12 -0
- package/dist/modules/o11y/web_vitals/library/RootActivityImpl.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/library/Tracing.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/shared/Utility.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/types/RootActivityHistoryEntry.d.ts +7 -0
- package/dist/modules/o11y/web_vitals/version.d.ts +1 -1
- package/package.json +2 -2
|
@@ -357,8 +357,8 @@ class PerformanceObservability {
|
|
|
357
357
|
this._fuzzyMapper.clear();
|
|
358
358
|
this._isStarted = false;
|
|
359
359
|
}
|
|
360
|
-
addEntry(
|
|
361
|
-
this._fuzzyMapper.add(
|
|
360
|
+
addEntry(absoluteUrl, perfTime, data) {
|
|
361
|
+
this._fuzzyMapper.add(absoluteUrl, perfTime, data);
|
|
362
362
|
}
|
|
363
363
|
_resourceEntryToResourceTiming(prt) {
|
|
364
364
|
var _a, _b;
|
|
@@ -451,9 +451,7 @@ class PerformanceObservability {
|
|
|
451
451
|
const payload = this._resourceEntryToResourceTiming(rt);
|
|
452
452
|
Object.assign(payload, {
|
|
453
453
|
srvReqId: requestInfo === null || requestInfo === void 0 ? void 0 : requestInfo.requestId,
|
|
454
|
-
xhrDelay: requestInfo
|
|
455
|
-
? requestInfo.activityDuration - (rt.startTime + rt.duration)
|
|
456
|
-
: undefined
|
|
454
|
+
xhrDelay: requestInfo ? requestInfo.activityDuration - rt.duration : undefined
|
|
457
455
|
});
|
|
458
456
|
this._logActivity(resource_timing, payload);
|
|
459
457
|
}
|
|
@@ -562,6 +560,11 @@ class Tracing {
|
|
|
562
560
|
Tracing._global.XMLHttpRequest.prototype.open = Tracing._originalXhrOpen;
|
|
563
561
|
Tracing._originalXhrOpen = undefined;
|
|
564
562
|
}
|
|
563
|
+
if (Tracing._originalXhrSetRequestHeader) {
|
|
564
|
+
Tracing._global.XMLHttpRequest.prototype.setRequestHeader =
|
|
565
|
+
Tracing._originalXhrSetRequestHeader;
|
|
566
|
+
Tracing._originalXhrSetRequestHeader = undefined;
|
|
567
|
+
}
|
|
565
568
|
if (Tracing._originalXhrSend) {
|
|
566
569
|
Tracing._global.XMLHttpRequest.prototype.send = Tracing._originalXhrSend;
|
|
567
570
|
Tracing._originalXhrSend = undefined;
|
|
@@ -632,6 +635,7 @@ class Tracing {
|
|
|
632
635
|
var _a;
|
|
633
636
|
let activity;
|
|
634
637
|
let url;
|
|
638
|
+
let absoluteUrl;
|
|
635
639
|
let method;
|
|
636
640
|
let fetchTime;
|
|
637
641
|
try {
|
|
@@ -658,14 +662,16 @@ class Tracing {
|
|
|
658
662
|
}
|
|
659
663
|
options === null || options === void 0 ? true : delete options.o11y;
|
|
660
664
|
url = resource === null || resource === void 0 ? void 0 : resource.toString();
|
|
665
|
+
absoluteUrl = utility.tryGetAbsoluteUrl(url);
|
|
661
666
|
if (useTracing) {
|
|
662
667
|
if (resource instanceof Request) {
|
|
663
668
|
if (!method) {
|
|
664
669
|
method = resource.method;
|
|
665
670
|
}
|
|
666
671
|
url = resource.url;
|
|
672
|
+
absoluteUrl = utility.tryGetAbsoluteUrl(url);
|
|
667
673
|
}
|
|
668
|
-
const traceHeaders = Tracing._getTraceHeaders(activity, tracingHeadersOptions, method,
|
|
674
|
+
const traceHeaders = Tracing._getTraceHeaders(activity, tracingHeadersOptions, method, absoluteUrl);
|
|
669
675
|
if (!this._applyTraceHeaders(resource, options, traceHeaders) &&
|
|
670
676
|
options === undefined) {
|
|
671
677
|
options = {
|
|
@@ -692,7 +698,7 @@ class Tracing {
|
|
|
692
698
|
const activityDuration = Tracing._endActivity(activity, url, method);
|
|
693
699
|
if ((_a = Tracing._performanceObservability) === null || _a === void 0 ? void 0 : _a.isStarted) {
|
|
694
700
|
const requestId = Tracing._extractHeader(headerRequestId, resource, options);
|
|
695
|
-
Tracing._performanceObservability.addEntry(
|
|
701
|
+
Tracing._performanceObservability.addEntry(absoluteUrl, fetchTime, {
|
|
696
702
|
requestId,
|
|
697
703
|
activityDuration
|
|
698
704
|
});
|
|
@@ -708,7 +714,7 @@ class Tracing {
|
|
|
708
714
|
static _endActivity(activity, url, method) {
|
|
709
715
|
var _a;
|
|
710
716
|
if (activity) {
|
|
711
|
-
if (
|
|
717
|
+
if (((_a = Tracing._performanceObservability) === null || _a === void 0 ? void 0 : _a.isStarted) && activity.getErrorCount() == 0) {
|
|
712
718
|
activity.discard();
|
|
713
719
|
}
|
|
714
720
|
else {
|
|
@@ -724,15 +730,15 @@ class Tracing {
|
|
|
724
730
|
_overrideXhr(instr, logErrors, activityName, useTracing, options, tasker) {
|
|
725
731
|
Tracing._originalXhr = Tracing._global.XMLHttpRequest;
|
|
726
732
|
Tracing._originalXhrOpen = Tracing._originalXhr.prototype.open;
|
|
733
|
+
Tracing._originalXhrSetRequestHeader = Tracing._originalXhr.prototype.setRequestHeader;
|
|
727
734
|
Tracing._originalXhrSend = Tracing._originalXhr.prototype.send;
|
|
728
735
|
function postProcess(xhr, failedAtInit) {
|
|
729
736
|
var _a;
|
|
730
737
|
if (xhr._o11y) {
|
|
731
738
|
const activityDuration = Tracing._endActivity(xhr._o11y.activity, xhr._o11y.url, xhr._o11y.method);
|
|
732
739
|
if (!failedAtInit && ((_a = Tracing._performanceObservability) === null || _a === void 0 ? void 0 : _a.isStarted)) {
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
requestId,
|
|
740
|
+
Tracing._performanceObservability.addEntry(xhr._o11y.absoluteUrl, xhr._o11y.sendTime, {
|
|
741
|
+
requestId: xhr._o11y.requestId,
|
|
736
742
|
activityDuration
|
|
737
743
|
});
|
|
738
744
|
}
|
|
@@ -743,8 +749,16 @@ class Tracing {
|
|
|
743
749
|
method,
|
|
744
750
|
url: url === null || url === void 0 ? void 0 : url.toString()
|
|
745
751
|
};
|
|
752
|
+
this._o11y.absoluteUrl = utility.tryGetAbsoluteUrl(this._o11y.url);
|
|
746
753
|
Tracing._originalXhrOpen.call(this, method, url, async, username, password);
|
|
747
754
|
};
|
|
755
|
+
Tracing._originalXhr.prototype.setRequestHeader = function (name, value) {
|
|
756
|
+
var _a;
|
|
757
|
+
if (((_a = name === null || name === void 0 ? void 0 : name.toLowerCase) === null || _a === void 0 ? void 0 : _a.call(name)) === headerRequestId.toLowerCase()) {
|
|
758
|
+
this._o11y.requestId = value;
|
|
759
|
+
}
|
|
760
|
+
Tracing._originalXhrSetRequestHeader.call(this, name, value);
|
|
761
|
+
};
|
|
748
762
|
Tracing._originalXhr.prototype.send = function (...args) {
|
|
749
763
|
let activity;
|
|
750
764
|
const xhr = this;
|
|
@@ -753,7 +767,7 @@ class Tracing {
|
|
|
753
767
|
xhr._o11y = xhr._o11y || {};
|
|
754
768
|
xhr._o11y.activity = activity = instr.startActivity(activityName || defaultActivityNameForXhrSend);
|
|
755
769
|
if (useTracing) {
|
|
756
|
-
const traceHeaders = Tracing._getTraceHeaders(activity, options, xhr._o11y.method, xhr._o11y.
|
|
770
|
+
const traceHeaders = Tracing._getTraceHeaders(activity, options, xhr._o11y.method, xhr._o11y.absoluteUrl);
|
|
757
771
|
Object.entries(traceHeaders).forEach((entry) => {
|
|
758
772
|
xhr.setRequestHeader(entry[0], entry[1]);
|
|
759
773
|
});
|
|
@@ -880,12 +894,13 @@ const stopReason = {
|
|
|
880
894
|
discarded
|
|
881
895
|
};
|
|
882
896
|
class ActivityImpl {
|
|
883
|
-
constructor(_name, _rootId, _onStopped, _onError, timeout, id, _isSampled) {
|
|
897
|
+
constructor(_name, _rootId, _onStopped, _onError, timeout, id, _isSampled, _startPerfTime, _noRerooting) {
|
|
884
898
|
this._name = _name;
|
|
885
899
|
this._rootId = _rootId;
|
|
886
900
|
this._onStopped = _onStopped;
|
|
887
901
|
this._onError = _onError;
|
|
888
902
|
this._isSampled = _isSampled;
|
|
903
|
+
this._noRerooting = _noRerooting;
|
|
889
904
|
this._errorCount = 0;
|
|
890
905
|
this._timerOverridden = TimerOverride.none;
|
|
891
906
|
const { tsNow, perfNow } = utility.time();
|
|
@@ -907,6 +922,7 @@ class ActivityImpl {
|
|
|
907
922
|
}
|
|
908
923
|
this._startTimestamp = tsNow;
|
|
909
924
|
this._startPerfTime = perfNow;
|
|
925
|
+
this._overrideTimer(_startPerfTime);
|
|
910
926
|
if (timeout > 0) {
|
|
911
927
|
this._timer = setTimeout(() => {
|
|
912
928
|
this._stopReason = this._stopReason || stopReason.timedout;
|
|
@@ -953,8 +969,9 @@ class ActivityImpl {
|
|
|
953
969
|
}
|
|
954
970
|
if (isStopTimeDefined &&
|
|
955
971
|
(perfStop < 0 ||
|
|
956
|
-
perfStop < (isStartTimeDefined ? perfStart : this._startPerfTime)
|
|
957
|
-
|
|
972
|
+
perfStop < (isStartTimeDefined ? perfStart : this._startPerfTime) ||
|
|
973
|
+
perfStop > utility.time().perfNow + 100)) {
|
|
974
|
+
throw new Error('perfStopOverride, if defined, must be >= 0 and >= startTime and <= now');
|
|
958
975
|
}
|
|
959
976
|
}
|
|
960
977
|
this._stopInternal(userSchemaOrText, userData, options);
|
|
@@ -1041,7 +1058,8 @@ class ActivityImpl {
|
|
|
1041
1058
|
stopPerfTime: this._stopPerfTime,
|
|
1042
1059
|
errorCount: this._errorCount,
|
|
1043
1060
|
isSampled: this.getIsSampled(),
|
|
1044
|
-
timerOverridden: this._timerOverridden
|
|
1061
|
+
timerOverridden: this._timerOverridden,
|
|
1062
|
+
noRerooting: this._noRerooting
|
|
1045
1063
|
};
|
|
1046
1064
|
}
|
|
1047
1065
|
getTraceHeaders(options) {
|
|
@@ -1572,8 +1590,10 @@ class InstrumentationImpl {
|
|
|
1572
1590
|
utility.requireArgument(name, 'name');
|
|
1573
1591
|
utility.requireArgumentIfDefined(options, 'options', 'object');
|
|
1574
1592
|
let context;
|
|
1593
|
+
let noRerooting = (options === null || options === void 0 ? void 0 : options.perfStartOverride) !== undefined;
|
|
1575
1594
|
const rootId = (_a = options === null || options === void 0 ? void 0 : options.instrumentationContext) === null || _a === void 0 ? void 0 : _a.rootId;
|
|
1576
1595
|
if (rootId) {
|
|
1596
|
+
noRerooting = true;
|
|
1577
1597
|
context = {
|
|
1578
1598
|
rootId,
|
|
1579
1599
|
isRootActivitySampled: options.instrumentationContext.isRootActivitySampled
|
|
@@ -1582,7 +1602,7 @@ class InstrumentationImpl {
|
|
|
1582
1602
|
else {
|
|
1583
1603
|
context = this._nextGen.getDefaultInstrumentationContext();
|
|
1584
1604
|
}
|
|
1585
|
-
const activity = new ActivityImpl(name, context.rootId, this._onActivityStoppedCallback, this._onActivityErrorCallback, maxActivityDurationMsecs, undefined, context.isRootActivitySampled);
|
|
1605
|
+
const activity = new ActivityImpl(name, context.rootId, this._onActivityStoppedCallback, this._onActivityErrorCallback, maxActivityDurationMsecs, undefined, context.isRootActivitySampled, options === null || options === void 0 ? void 0 : options.perfStartOverride, noRerooting);
|
|
1586
1606
|
return activity;
|
|
1587
1607
|
}, activityNoOp);
|
|
1588
1608
|
}
|
|
@@ -1596,13 +1616,22 @@ class InstrumentationImpl {
|
|
|
1596
1616
|
userPayload,
|
|
1597
1617
|
errorCount: detail.errorCount,
|
|
1598
1618
|
isSampled: detail.isSampled,
|
|
1599
|
-
timerOverridden: detail.timerOverridden
|
|
1619
|
+
timerOverridden: detail.timerOverridden,
|
|
1620
|
+
isRerooted: detail.isRerooted
|
|
1600
1621
|
};
|
|
1601
1622
|
}
|
|
1602
1623
|
_handleActivityStop(detail) {
|
|
1603
1624
|
if (detail.stopReason === discarded) {
|
|
1604
1625
|
return;
|
|
1605
1626
|
}
|
|
1627
|
+
if (!detail.isRoot && !detail.noRerooting) {
|
|
1628
|
+
const rahe = this._nextGen.getRootActivityHistoryEntryByTime(detail.startPerfTime);
|
|
1629
|
+
if ((!rahe && detail.rootId !== undefined) || (rahe && detail.rootId !== rahe.id)) {
|
|
1630
|
+
detail.rootId = rahe === null || rahe === void 0 ? void 0 : rahe.id;
|
|
1631
|
+
detail.isSampled = (rahe === null || rahe === void 0 ? void 0 : rahe.isSampled) || false;
|
|
1632
|
+
detail.isRerooted = true;
|
|
1633
|
+
}
|
|
1634
|
+
}
|
|
1606
1635
|
const activityData = this._getActivityData(detail);
|
|
1607
1636
|
this._logActivity(activityData, detail.startTimestamp, detail.rootId);
|
|
1608
1637
|
}
|
|
@@ -1726,9 +1755,17 @@ class InstrumentationImpl {
|
|
|
1726
1755
|
utility.requireArgument(listener, 'listener', 'function');
|
|
1727
1756
|
this._nextGen.registerForLogPrompt(listener);
|
|
1728
1757
|
}
|
|
1758
|
+
_getAsaOptions(options) {
|
|
1759
|
+
return options
|
|
1760
|
+
? Object.assign({
|
|
1761
|
+
instrumentationContext: options === null || options === void 0 ? void 0 : options.instrumentationContext
|
|
1762
|
+
}, options.startOptions)
|
|
1763
|
+
: undefined;
|
|
1764
|
+
}
|
|
1729
1765
|
activity(name, execute, options) {
|
|
1730
1766
|
var _a, _b, _c, _d;
|
|
1731
|
-
const
|
|
1767
|
+
const asaOptions = this._getAsaOptions(options);
|
|
1768
|
+
const act = this.startActivity(name, asaOptions);
|
|
1732
1769
|
try {
|
|
1733
1770
|
return execute(act);
|
|
1734
1771
|
}
|
|
@@ -1737,12 +1774,13 @@ class InstrumentationImpl {
|
|
|
1737
1774
|
throw err;
|
|
1738
1775
|
}
|
|
1739
1776
|
finally {
|
|
1740
|
-
act.stop((_c = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _c === void 0 ? void 0 : _c.schema, (_d = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _d === void 0 ? void 0 : _d.payload);
|
|
1777
|
+
act.stop((_c = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _c === void 0 ? void 0 : _c.schema, (_d = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _d === void 0 ? void 0 : _d.payload, options === null || options === void 0 ? void 0 : options.stopOptions);
|
|
1741
1778
|
}
|
|
1742
1779
|
}
|
|
1743
1780
|
async activityAsync(name, execute, options) {
|
|
1744
1781
|
var _a, _b, _c, _d;
|
|
1745
|
-
const
|
|
1782
|
+
const asaOptions = this._getAsaOptions(options);
|
|
1783
|
+
const act = this.startActivity(name, asaOptions);
|
|
1746
1784
|
try {
|
|
1747
1785
|
return await execute(act);
|
|
1748
1786
|
}
|
|
@@ -1751,15 +1789,66 @@ class InstrumentationImpl {
|
|
|
1751
1789
|
throw err;
|
|
1752
1790
|
}
|
|
1753
1791
|
finally {
|
|
1754
|
-
act.stop((_c = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _c === void 0 ? void 0 : _c.schema, (_d = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _d === void 0 ? void 0 : _d.payload);
|
|
1792
|
+
act.stop((_c = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _c === void 0 ? void 0 : _c.schema, (_d = options === null || options === void 0 ? void 0 : options.stopPayload) === null || _d === void 0 ? void 0 : _d.payload, options === null || options === void 0 ? void 0 : options.stopOptions);
|
|
1755
1793
|
}
|
|
1756
1794
|
}
|
|
1757
1795
|
}
|
|
1758
1796
|
InstrumentationImpl.defaultAppName = 'APP_NOT_REGISTERED';
|
|
1759
1797
|
|
|
1798
|
+
const GRACE = 0.1;
|
|
1799
|
+
const DEFAULT_LIMIT = 20;
|
|
1800
|
+
class RootActivityHistoryImpl {
|
|
1801
|
+
constructor(limit) {
|
|
1802
|
+
this._historyMap = new Map();
|
|
1803
|
+
this._historyList = new Array();
|
|
1804
|
+
if (utility.requireArgumentIfDefined(limit, 'limit', 'number')) {
|
|
1805
|
+
limit = Math.ceil(limit);
|
|
1806
|
+
if (limit <= 0) {
|
|
1807
|
+
throw new Error('Limit must be a positive number');
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
else {
|
|
1811
|
+
limit = DEFAULT_LIMIT;
|
|
1812
|
+
}
|
|
1813
|
+
this._graceCount = Math.max(1, Math.floor(limit * GRACE));
|
|
1814
|
+
this._realLimit = 1 + limit + this._graceCount;
|
|
1815
|
+
}
|
|
1816
|
+
add(entry) {
|
|
1817
|
+
if (this._historyMap.has(entry.id)) {
|
|
1818
|
+
throw new Error(`RootActivityHistoryImpl.add: entry already exists for rootId: ${entry.id}`);
|
|
1819
|
+
}
|
|
1820
|
+
this._historyMap.set(entry.id, entry);
|
|
1821
|
+
this._historyList.push(entry);
|
|
1822
|
+
if (this._historyList.length === this._realLimit) {
|
|
1823
|
+
const removed = this._historyList.splice(1, this._graceCount);
|
|
1824
|
+
removed.forEach((e) => this._historyMap.delete(e.id));
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
get count() {
|
|
1828
|
+
return this._historyList.length;
|
|
1829
|
+
}
|
|
1830
|
+
findById(rootId) {
|
|
1831
|
+
return this._historyMap.get(rootId);
|
|
1832
|
+
}
|
|
1833
|
+
findByTime(atTime) {
|
|
1834
|
+
let closest;
|
|
1835
|
+
let closestDiff = Number.MAX_VALUE;
|
|
1836
|
+
for (const entry of this._historyList) {
|
|
1837
|
+
const startDelta = atTime - entry.startPerfTime;
|
|
1838
|
+
const isDuringRoot = startDelta >= 0 &&
|
|
1839
|
+
(entry.stopPerfTime === undefined || atTime < entry.stopPerfTime);
|
|
1840
|
+
if (isDuringRoot && startDelta < closestDiff) {
|
|
1841
|
+
closest = entry;
|
|
1842
|
+
closestDiff = startDelta;
|
|
1843
|
+
}
|
|
1844
|
+
}
|
|
1845
|
+
return closest;
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1848
|
+
|
|
1760
1849
|
class RootActivityImpl extends ActivityImpl {
|
|
1761
|
-
constructor(name, onStopped, onError, rootId,
|
|
1762
|
-
super(name, undefined, onStopped, onError, undefined, rootId || utility.generateUniqueId(32),
|
|
1850
|
+
constructor(name, onStopped, onError, rootId, isSampled, startPerfTime) {
|
|
1851
|
+
super(name, undefined, onStopped, onError, undefined, rootId || utility.generateUniqueId(32), isSampled, startPerfTime);
|
|
1763
1852
|
}
|
|
1764
1853
|
get preRootId() {
|
|
1765
1854
|
return this._preRootId;
|
|
@@ -1812,13 +1901,21 @@ class AppInstrumentationImpl extends InstrumentationImpl {
|
|
|
1812
1901
|
constructor(_nextGen, _name, _allowMulti) {
|
|
1813
1902
|
super(_nextGen, _name);
|
|
1814
1903
|
this._allowMulti = _allowMulti;
|
|
1904
|
+
this._rootActivityHistory = new RootActivityHistoryImpl();
|
|
1815
1905
|
this._onRootActivityStoppedCallback = this._handleRootActivityStop.bind(this);
|
|
1816
1906
|
}
|
|
1817
|
-
startRootActivity(name, rootId, isSampled) {
|
|
1907
|
+
startRootActivity(name, rootId, isSampled, options) {
|
|
1818
1908
|
return this._safety.tryCatchReturn(() => {
|
|
1819
1909
|
utility.requireArgument(name, 'name');
|
|
1820
|
-
const newRootActivity = new RootActivityImpl(name, this._onRootActivityStoppedCallback, this._onActivityErrorCallback, rootId, isSampled);
|
|
1910
|
+
const newRootActivity = new RootActivityImpl(name, this._onRootActivityStoppedCallback, this._onActivityErrorCallback, rootId, isSampled, options === null || options === void 0 ? void 0 : options.perfStartOverride);
|
|
1821
1911
|
if (!this._allowMulti) {
|
|
1912
|
+
const entry = {
|
|
1913
|
+
id: newRootActivity.getId(),
|
|
1914
|
+
name,
|
|
1915
|
+
startPerfTime: newRootActivity.getStartPerfTime(),
|
|
1916
|
+
isSampled: newRootActivity.getIsSampled()
|
|
1917
|
+
};
|
|
1918
|
+
this._rootActivityHistory.add(entry);
|
|
1822
1919
|
if (this._singleRootActivity && !this._singleRootActivity.isStopped) {
|
|
1823
1920
|
const preRootId = this._singleRootActivity.getId();
|
|
1824
1921
|
this._singleRootActivity.terminate();
|
|
@@ -1830,6 +1927,11 @@ class AppInstrumentationImpl extends InstrumentationImpl {
|
|
|
1830
1927
|
}, rootActivityNoOp);
|
|
1831
1928
|
}
|
|
1832
1929
|
_handleRootActivityStop(detail) {
|
|
1930
|
+
const historyEntry = this._rootActivityHistory.findById(detail.id);
|
|
1931
|
+
if (historyEntry) {
|
|
1932
|
+
historyEntry.stopPerfTime = detail.stopPerfTime;
|
|
1933
|
+
historyEntry.startPerfTime = detail.startPerfTime;
|
|
1934
|
+
}
|
|
1833
1935
|
if (detail.stopReason === discarded) {
|
|
1834
1936
|
return;
|
|
1835
1937
|
}
|
|
@@ -1854,6 +1956,9 @@ class AppInstrumentationImpl extends InstrumentationImpl {
|
|
|
1854
1956
|
_initMetrics() {
|
|
1855
1957
|
return new MetricsImpl(this.name, () => this.name);
|
|
1856
1958
|
}
|
|
1959
|
+
getRootActivityHistoryEntry(atTime) {
|
|
1960
|
+
return this._rootActivityHistory.findByTime(atTime);
|
|
1961
|
+
}
|
|
1857
1962
|
}
|
|
1858
1963
|
|
|
1859
1964
|
const pathLimit = 5;
|
|
@@ -2219,6 +2324,10 @@ class NextgenImpl {
|
|
|
2219
2324
|
var _a;
|
|
2220
2325
|
return (_a = this._appInstr) === null || _a === void 0 ? void 0 : _a.name;
|
|
2221
2326
|
}
|
|
2327
|
+
getRootActivityHistoryEntryByTime(atTime) {
|
|
2328
|
+
var _a;
|
|
2329
|
+
return (_a = this._appInstr) === null || _a === void 0 ? void 0 : _a.getRootActivityHistoryEntry(atTime);
|
|
2330
|
+
}
|
|
2222
2331
|
addLog(loggerName, schema, data, timestamp, rootId) {
|
|
2223
2332
|
var _a, _b, _c;
|
|
2224
2333
|
payloadUtility.checkInputs(schema, data);
|
|
@@ -2519,7 +2628,7 @@ class ConsoleCollector {
|
|
|
2519
2628
|
}
|
|
2520
2629
|
}
|
|
2521
2630
|
|
|
2522
|
-
const version = '
|
|
2631
|
+
const version = '250.1.0';
|
|
2523
2632
|
|
|
2524
2633
|
const idleDetector = new IdleDetectorImpl({
|
|
2525
2634
|
logThreshold: 300,
|