o11y 252.7.0 → 252.8.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.
Files changed (24) hide show
  1. package/dist/modules/o11y/client/client.js +59 -18
  2. package/dist/modules/o11y/client/client.js.map +1 -1
  3. package/dist/modules/o11y/client/library/InstrumentationImpl.d.ts +2 -1
  4. package/dist/modules/o11y/client/library/Tracing.d.ts +1 -0
  5. package/dist/modules/o11y/client/version.d.ts +1 -1
  6. package/dist/modules/o11y/collectors/library/InstrumentationImpl.d.ts +2 -1
  7. package/dist/modules/o11y/collectors/library/Tracing.d.ts +1 -0
  8. package/dist/modules/o11y/collectors/version.d.ts +1 -1
  9. package/dist/modules/o11y/core_envelope/library/InstrumentationImpl.d.ts +2 -1
  10. package/dist/modules/o11y/core_envelope/library/Tracing.d.ts +1 -0
  11. package/dist/modules/o11y/core_envelope/version.d.ts +1 -1
  12. package/dist/modules/o11y/shared/library/InstrumentationImpl.d.ts +2 -1
  13. package/dist/modules/o11y/shared/library/Tracing.d.ts +1 -0
  14. package/dist/modules/o11y/shared/shared.js +2 -1
  15. package/dist/modules/o11y/shared/shared.js.map +1 -1
  16. package/dist/modules/o11y/shared/version.d.ts +1 -1
  17. package/dist/modules/o11y/simple_collector/library/InstrumentationImpl.d.ts +2 -1
  18. package/dist/modules/o11y/simple_collector/library/Tracing.d.ts +1 -0
  19. package/dist/modules/o11y/simple_collector/version.d.ts +1 -1
  20. package/dist/modules/o11y/web_vitals/library/InstrumentationImpl.d.ts +2 -1
  21. package/dist/modules/o11y/web_vitals/library/Tracing.d.ts +1 -0
  22. package/dist/modules/o11y/web_vitals/version.d.ts +1 -1
  23. package/dist/modules/o11y/web_vitals/web_vitals.js.map +1 -1
  24. package/package.json +1 -1
@@ -584,11 +584,11 @@ class Tracing {
584
584
  }
585
585
  _enableNetworkInstrumentation(instr, logErrors, activityName, useTracing, options, tasker, logPerformance, logPerformanceActivityName, skipUrls, fuzzyMapRange) {
586
586
  if (typeof Tracing._global.fetch === 'function') {
587
- this._overrideFetch(instr, logErrors, activityName, useTracing, options, tasker);
587
+ this._overrideFetch(instr, logErrors, activityName, useTracing, options, tasker, skipUrls);
588
588
  Tracing._isNetworkInstrumentationEnabled = true;
589
589
  }
590
590
  if (typeof Tracing._global.XMLHttpRequest === 'function') {
591
- this._overrideXhr(instr, logErrors, activityName, useTracing, options, tasker);
591
+ this._overrideXhr(instr, logErrors, activityName, useTracing, options, tasker, skipUrls);
592
592
  Tracing._isNetworkInstrumentationEnabled = true;
593
593
  }
594
594
  if (logPerformance) {
@@ -597,8 +597,20 @@ class Tracing {
597
597
  Tracing._isNetworkInstrumentationEnabled = true;
598
598
  }
599
599
  }
600
- static _getTraceHeaders(activity, options, method, url) {
601
- let traceHeaders = (activity === null || activity === void 0 ? void 0 : activity.getTraceHeaders(options)) || {};
600
+ static _getTraceHeaders(activity, tracingInstr, options, method, url) {
601
+ let traceHeaders;
602
+ if (activity) {
603
+ traceHeaders = activity.getTraceHeaders(options) || {};
604
+ }
605
+ else {
606
+ const context = tracingInstr.internalInstrumentationContext;
607
+ if (context === null || context === void 0 ? void 0 : context.rootId) {
608
+ traceHeaders = Tracing.getHeaders(context.rootId, utility.generateUniqueId(), context.isRootActivitySampled, options);
609
+ }
610
+ else {
611
+ traceHeaders = {};
612
+ }
613
+ }
602
614
  if (typeof (options === null || options === void 0 ? void 0 : options.headerProcessor) === 'function') {
603
615
  traceHeaders = options.headerProcessor({
604
616
  method,
@@ -635,7 +647,7 @@ class Tracing {
635
647
  }
636
648
  return undefined;
637
649
  }
638
- _overrideFetch(instr, logErrors, activityName, useTracing, tracingHeadersOptions, tasker) {
650
+ _overrideFetch(instr, logErrors, activityName, useTracing, tracingHeadersOptions, tasker, skipUrls) {
639
651
  Tracing._originalFetch = Tracing._global.fetch;
640
652
  const o11yFetch = async (resource, options, ...restArgs) => {
641
653
  var _a;
@@ -644,14 +656,18 @@ class Tracing {
644
656
  let absoluteUrl;
645
657
  let method;
646
658
  let fetchTime;
659
+ let suspendInstrumentation = false;
647
660
  try {
648
661
  tasker === null || tasker === void 0 ? void 0 : tasker.add();
649
662
  method = options === null || options === void 0 ? void 0 : options.method;
650
663
  const ofo = options === null || options === void 0 ? void 0 : options.o11y;
651
- if (!(ofo === null || ofo === void 0 ? void 0 : ofo.skipInstr)) {
664
+ const isSkipInstrSet = ofo === null || ofo === void 0 ? void 0 : ofo.skipInstr;
665
+ suspendInstrumentation =
666
+ isSkipInstrSet || Tracing._shouldSkipUrl(skipUrls, resource);
667
+ if (!suspendInstrumentation) {
652
668
  activity = instr.startActivity(activityName || defaultActivityNameForFetch);
653
669
  }
654
- else {
670
+ else if (isSkipInstrSet) {
655
671
  Tracing._reqIndex += 1;
656
672
  try {
657
673
  if (resource instanceof URL) {
@@ -677,7 +693,7 @@ class Tracing {
677
693
  url = resource.url;
678
694
  absoluteUrl = utility.tryGetAbsoluteUrl(url);
679
695
  }
680
- const traceHeaders = Tracing._getTraceHeaders(activity, tracingHeadersOptions, method, absoluteUrl);
696
+ const traceHeaders = Tracing._getTraceHeaders(activity, instr, tracingHeadersOptions, method, absoluteUrl);
681
697
  if (!this._applyTraceHeaders(resource, options, traceHeaders) &&
682
698
  options === undefined) {
683
699
  options = {
@@ -689,7 +705,7 @@ class Tracing {
689
705
  return await Tracing._originalFetch.call(Tracing._global, resource, options, ...restArgs);
690
706
  }
691
707
  catch (ex) {
692
- if (logErrors) {
708
+ if (logErrors && !suspendInstrumentation) {
693
709
  if (activity) {
694
710
  activity.error(ex);
695
711
  }
@@ -735,7 +751,7 @@ class Tracing {
735
751
  }
736
752
  return undefined;
737
753
  }
738
- _overrideXhr(instr, logErrors, activityName, useTracing, options, tasker) {
754
+ _overrideXhr(instr, logErrors, activityName, useTracing, options, tasker, skipUrls) {
739
755
  Tracing._originalXhr = Tracing._global.XMLHttpRequest;
740
756
  Tracing._originalXhrOpen = Tracing._originalXhr.prototype.open;
741
757
  Tracing._originalXhrSetRequestHeader = Tracing._originalXhr.prototype.setRequestHeader;
@@ -761,6 +777,7 @@ class Tracing {
761
777
  url: url === null || url === void 0 ? void 0 : url.toString()
762
778
  };
763
779
  this._o11y.absoluteUrl = utility.tryGetAbsoluteUrl(this._o11y.url);
780
+ this._o11y.suspendInstrumentation = Tracing._shouldSkipUrl(skipUrls, this._o11y.absoluteUrl);
764
781
  Tracing._originalXhrOpen.apply(this, arguments);
765
782
  };
766
783
  Tracing._originalXhr.prototype.setRequestHeader = function (name, value) {
@@ -771,14 +788,17 @@ class Tracing {
771
788
  Tracing._originalXhrSetRequestHeader.apply(this, arguments);
772
789
  };
773
790
  Tracing._originalXhr.prototype.send = function (...args) {
791
+ var _a;
774
792
  let activity;
775
793
  const xhr = this;
776
794
  try {
777
795
  tasker === null || tasker === void 0 ? void 0 : tasker.add();
778
796
  xhr._o11y = xhr._o11y || {};
779
- xhr._o11y.activity = activity = instr.startActivity(activityName || defaultActivityNameForXhrSend);
797
+ if (!xhr._o11y.suspendInstrumentation) {
798
+ xhr._o11y.activity = activity = instr.startActivity(activityName || defaultActivityNameForXhrSend);
799
+ }
780
800
  if (useTracing) {
781
- const traceHeaders = Tracing._getTraceHeaders(activity, options, xhr._o11y.method, xhr._o11y.absoluteUrl);
801
+ const traceHeaders = Tracing._getTraceHeaders(activity, instr, options, xhr._o11y.method, xhr._o11y.absoluteUrl);
782
802
  Object.entries(traceHeaders).forEach((entry) => {
783
803
  xhr.setRequestHeader(entry[0], entry[1]);
784
804
  });
@@ -787,7 +807,7 @@ class Tracing {
787
807
  Tracing._originalXhrSend.call(this, ...args);
788
808
  }
789
809
  catch (ex) {
790
- if (logErrors) {
810
+ if (logErrors && !((_a = xhr._o11y) === null || _a === void 0 ? void 0 : _a.suspendInstrumentation)) {
791
811
  if (activity) {
792
812
  activity.error(ex);
793
813
  }
@@ -808,11 +828,11 @@ class Tracing {
808
828
  tasker === null || tasker === void 0 ? void 0 : tasker.done();
809
829
  });
810
830
  newXhr.addEventListener('error', (__err) => {
811
- var _a;
831
+ var _a, _b;
812
832
  try {
813
- const error = new Error('XHR Network-Level Error');
814
- if (logErrors) {
815
- const activity = (_a = newXhr._o11y) === null || _a === void 0 ? void 0 : _a.activity;
833
+ if (logErrors && !((_a = newXhr._o11y) === null || _a === void 0 ? void 0 : _a.suspendInstrumentation)) {
834
+ const error = new Error('XHR Network-Level Error');
835
+ const activity = (_b = newXhr._o11y) === null || _b === void 0 ? void 0 : _b.activity;
816
836
  if (activity) {
817
837
  activity.error(error);
818
838
  }
@@ -883,6 +903,24 @@ class Tracing {
883
903
  }
884
904
  return false;
885
905
  }
906
+ static _shouldSkipUrl(skipUrls, urlLike) {
907
+ var _a;
908
+ let url = urlLike;
909
+ if (urlLike instanceof URL) {
910
+ url = (_a = urlLike.toString) === null || _a === void 0 ? void 0 : _a.call(urlLike);
911
+ }
912
+ else if (urlLike instanceof Request) {
913
+ url = urlLike.url;
914
+ }
915
+ return skipUrls === null || skipUrls === void 0 ? void 0 : skipUrls.some((skipUrl) => {
916
+ if (skipUrl instanceof RegExp) {
917
+ return skipUrl.test(url);
918
+ }
919
+ else {
920
+ return url === skipUrl;
921
+ }
922
+ });
923
+ }
886
924
  }
887
925
  Tracing._global = utility.getGlobal();
888
926
  Tracing._isNetworkInstrumentationEnabled = false;
@@ -1487,6 +1525,9 @@ class InstrumentationImpl {
1487
1525
  var _a, _b;
1488
1526
  return ((_b = (_a = options === null || options === void 0 ? void 0 : options.instrumentationContext) === null || _a === void 0 ? void 0 : _a.rootId) !== null && _b !== void 0 ? _b : this._nextGen.getDefaultInstrumentationContext().rootId);
1489
1527
  }
1528
+ get internalInstrumentationContext() {
1529
+ return this._nextGen.getDefaultInstrumentationContext();
1530
+ }
1490
1531
  log(userSchemaOrText, userData, options) {
1491
1532
  this._safety.tryCatch(() => {
1492
1533
  const timestamp = utility.time().tsNow;
@@ -2614,7 +2655,7 @@ class ConsoleCollector {
2614
2655
  }
2615
2656
  }
2616
2657
 
2617
- const version = '252.7.0';
2658
+ const version = '252.8.0';
2618
2659
 
2619
2660
  const idleDetector = new IdleDetectorImpl({
2620
2661
  logThreshold: 300,