o11y 260.23.0 → 262.4.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.
@@ -442,6 +442,25 @@ class PerformanceObservability {
442
442
  return (basicInitiatorTypes.indexOf(entry.initiatorType) >= 0 ||
443
443
  entry.entryType === 'navigation');
444
444
  }
445
+ _calculateXhrDelay(rt, requestInfo) {
446
+ if (!requestInfo) {
447
+ return undefined;
448
+ }
449
+ if (rt.initiatorType === 'fetch') {
450
+ if (rt.responseStart === 0) {
451
+ return -1;
452
+ }
453
+ if (requestInfo.activityDuration !== undefined) {
454
+ const timeUntilFetchReadyToResolve = rt.responseStart - rt.startTime;
455
+ return requestInfo.activityDuration - timeUntilFetchReadyToResolve;
456
+ }
457
+ return undefined;
458
+ }
459
+ if (requestInfo.activityDuration !== undefined) {
460
+ return requestInfo.activityDuration - rt.duration;
461
+ }
462
+ return undefined;
463
+ }
445
464
  _logActivity(schema, payload, activityId, errorCount) {
446
465
  const startOptions = {
447
466
  id: activityId
@@ -490,7 +509,7 @@ class PerformanceObservability {
490
509
  const payload = this._resourceEntryToResourceTiming(rt);
491
510
  Object.assign(payload, {
492
511
  srvReqId: requestInfo === null || requestInfo === void 0 ? void 0 : requestInfo.requestId,
493
- xhrDelay: requestInfo ? requestInfo.activityDuration - rt.duration : undefined
512
+ xhrDelay: this._calculateXhrDelay(rt, requestInfo)
494
513
  });
495
514
  if (payload.responseStatus === undefined) {
496
515
  payload.responseStatus = requestInfo === null || requestInfo === void 0 ? void 0 : requestInfo.responseStatus;
@@ -788,13 +807,14 @@ class Tracing {
788
807
  const activityDuration = Tracing._endActivity(activity, url, method);
789
808
  if ((_a = Tracing._performanceObservability) === null || _a === void 0 ? void 0 : _a.isStarted) {
790
809
  const requestId = Tracing._extractHeader(headerRequestId, resource, options);
791
- Tracing._performanceObservability.addEntry(absoluteUrl, fetchTime, {
810
+ const metadata = {
792
811
  requestId,
793
812
  activityDuration,
794
813
  activityId: activity === null || activity === void 0 ? void 0 : activity.getId(),
795
814
  errorCount: activity === null || activity === void 0 ? void 0 : activity.getErrorCount(),
796
815
  responseStatus: response === null || response === void 0 ? void 0 : response.status
797
- });
816
+ };
817
+ Tracing._performanceObservability.addEntry(absoluteUrl, fetchTime, metadata);
798
818
  }
799
819
  }
800
820
  finally {