o11y 244.4.8 → 244.7.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 +71 -16
- package/dist/modules/o11y/client/client.js.map +1 -1
- package/dist/modules/o11y/client/interfaces/Activity.d.ts +2 -2
- package/dist/modules/o11y/client/interfaces/HeaderProcessorArgs.d.ts +6 -0
- package/dist/modules/o11y/client/interfaces/TracingHeadersOptions.d.ts +3 -0
- package/dist/modules/o11y/client/library/ActivityImpl.d.ts +2 -2
- package/dist/modules/o11y/client/library/Tracing.d.ts +6 -1
- package/dist/modules/o11y/client/shared/TypeDefinitions.d.ts +1 -0
- package/dist/modules/o11y/client/version.d.ts +1 -1
- package/dist/modules/o11y/collectors/interfaces/Activity.d.ts +2 -2
- package/dist/modules/o11y/collectors/interfaces/HeaderProcessorArgs.d.ts +6 -0
- package/dist/modules/o11y/collectors/interfaces/TracingHeadersOptions.d.ts +3 -0
- package/dist/modules/o11y/collectors/library/ActivityImpl.d.ts +2 -2
- package/dist/modules/o11y/collectors/library/Tracing.d.ts +6 -1
- package/dist/modules/o11y/collectors/shared/TypeDefinitions.d.ts +1 -0
- package/dist/modules/o11y/collectors/version.d.ts +1 -1
- package/dist/modules/o11y/core_envelope/interfaces/Activity.d.ts +2 -2
- package/dist/modules/o11y/core_envelope/interfaces/HeaderProcessorArgs.d.ts +6 -0
- package/dist/modules/o11y/core_envelope/interfaces/TracingHeadersOptions.d.ts +3 -0
- package/dist/modules/o11y/core_envelope/library/ActivityImpl.d.ts +2 -2
- package/dist/modules/o11y/core_envelope/library/Tracing.d.ts +6 -1
- package/dist/modules/o11y/core_envelope/shared/TypeDefinitions.d.ts +1 -0
- package/dist/modules/o11y/core_envelope/version.d.ts +1 -1
- package/dist/modules/o11y/shared/interfaces/Activity.d.ts +2 -2
- package/dist/modules/o11y/shared/interfaces/HeaderProcessorArgs.d.ts +6 -0
- package/dist/modules/o11y/shared/interfaces/TracingHeadersOptions.d.ts +3 -0
- package/dist/modules/o11y/shared/library/ActivityImpl.d.ts +2 -2
- package/dist/modules/o11y/shared/library/Tracing.d.ts +6 -1
- package/dist/modules/o11y/shared/shared/TypeDefinitions.d.ts +1 -0
- package/dist/modules/o11y/shared/version.d.ts +1 -1
- package/dist/modules/o11y/simple_collector/interfaces/Activity.d.ts +2 -2
- package/dist/modules/o11y/simple_collector/interfaces/HeaderProcessorArgs.d.ts +6 -0
- package/dist/modules/o11y/simple_collector/interfaces/TracingHeadersOptions.d.ts +3 -0
- package/dist/modules/o11y/simple_collector/library/ActivityImpl.d.ts +2 -2
- package/dist/modules/o11y/simple_collector/library/Tracing.d.ts +6 -1
- package/dist/modules/o11y/simple_collector/shared/TypeDefinitions.d.ts +1 -0
- package/dist/modules/o11y/simple_collector/version.d.ts +1 -1
- package/dist/modules/o11y/web_vitals/interfaces/Activity.d.ts +2 -2
- package/dist/modules/o11y/web_vitals/interfaces/HeaderProcessorArgs.d.ts +6 -0
- package/dist/modules/o11y/web_vitals/interfaces/TracingHeadersOptions.d.ts +3 -0
- package/dist/modules/o11y/web_vitals/library/ActivityImpl.d.ts +2 -2
- package/dist/modules/o11y/web_vitals/library/Tracing.d.ts +6 -1
- package/dist/modules/o11y/web_vitals/shared/TypeDefinitions.d.ts +1 -0
- package/dist/modules/o11y/web_vitals/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -354,6 +354,10 @@ class Tracing {
|
|
|
354
354
|
Tracing._global.XMLHttpRequest = Tracing._originalXhr;
|
|
355
355
|
Tracing._originalXhr = undefined;
|
|
356
356
|
}
|
|
357
|
+
if (Tracing._originalXhrOpen) {
|
|
358
|
+
Tracing._global.XMLHttpRequest.prototype.open = Tracing._originalXhrOpen;
|
|
359
|
+
Tracing._originalXhrOpen = undefined;
|
|
360
|
+
}
|
|
357
361
|
if (Tracing._originalXhrSend) {
|
|
358
362
|
Tracing._global.XMLHttpRequest.prototype.send = Tracing._originalXhrSend;
|
|
359
363
|
Tracing._originalXhrSend = undefined;
|
|
@@ -371,16 +375,56 @@ class Tracing {
|
|
|
371
375
|
Tracing._isNetworkInstrumentationEnabled = true;
|
|
372
376
|
}
|
|
373
377
|
}
|
|
378
|
+
static _getTraceHeaders(activity, options, method, url) {
|
|
379
|
+
let traceHeaders = (activity === null || activity === void 0 ? void 0 : activity.getTraceHeaders(options)) || {};
|
|
380
|
+
if (typeof (options === null || options === void 0 ? void 0 : options.headerProcessor) === 'function') {
|
|
381
|
+
traceHeaders = options.headerProcessor({
|
|
382
|
+
method,
|
|
383
|
+
url,
|
|
384
|
+
defaultHeaders: traceHeaders
|
|
385
|
+
});
|
|
386
|
+
}
|
|
387
|
+
else if (typeof window === 'object') {
|
|
388
|
+
let newUrl;
|
|
389
|
+
try {
|
|
390
|
+
newUrl = new URL(url);
|
|
391
|
+
}
|
|
392
|
+
catch (_a) {
|
|
393
|
+
}
|
|
394
|
+
if (newUrl && newUrl.host !== window.location.host) {
|
|
395
|
+
traceHeaders = undefined;
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
return traceHeaders || {};
|
|
399
|
+
}
|
|
374
400
|
_overrideFetch(instr, logErrors, activityName, useTracing, options, tasker) {
|
|
375
401
|
Tracing._originalFetch = Tracing._global.fetch;
|
|
376
402
|
const o11yFetch = async (url, reqOptions, ...restArgs) => {
|
|
377
403
|
let activity;
|
|
378
404
|
try {
|
|
379
405
|
tasker === null || tasker === void 0 ? void 0 : tasker.add();
|
|
380
|
-
|
|
406
|
+
const ofo = reqOptions === null || reqOptions === void 0 ? void 0 : reqOptions.o11y;
|
|
407
|
+
if (!(ofo === null || ofo === void 0 ? void 0 : ofo.skipInstr)) {
|
|
408
|
+
activity = instr.startActivity(activityName || defaultActivityNameForFetch);
|
|
409
|
+
}
|
|
410
|
+
else {
|
|
411
|
+
Tracing._reqIndex += 1;
|
|
412
|
+
try {
|
|
413
|
+
if (typeof url === 'string') {
|
|
414
|
+
const urlObj = new URL(url);
|
|
415
|
+
const kv = `o11y=${Tracing._reqIndex}`;
|
|
416
|
+
urlObj.search += urlObj.search.startsWith('?') ? `&${kv}` : kv;
|
|
417
|
+
url = urlObj.toString();
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
catch (_a) { }
|
|
421
|
+
}
|
|
422
|
+
if (reqOptions) {
|
|
423
|
+
delete reqOptions.o11y;
|
|
424
|
+
}
|
|
381
425
|
if (useTracing) {
|
|
382
426
|
reqOptions = reqOptions || {};
|
|
383
|
-
const traceHeaders = activity.
|
|
427
|
+
const traceHeaders = Tracing._getTraceHeaders(activity, options, reqOptions.method, url === null || url === void 0 ? void 0 : url.toString());
|
|
384
428
|
reqOptions.headers = Object.assign(reqOptions.headers || {}, traceHeaders);
|
|
385
429
|
}
|
|
386
430
|
return await Tracing._originalFetch.call(Tracing._global, url, reqOptions, ...restArgs);
|
|
@@ -405,16 +449,25 @@ class Tracing {
|
|
|
405
449
|
}
|
|
406
450
|
_overrideXhr(instr, logErrors, activityName, useTracing, options, tasker) {
|
|
407
451
|
Tracing._originalXhr = Tracing._global.XMLHttpRequest;
|
|
452
|
+
Tracing._originalXhrOpen = Tracing._originalXhr.prototype.open;
|
|
408
453
|
Tracing._originalXhrSend = Tracing._originalXhr.prototype.send;
|
|
454
|
+
Tracing._originalXhr.prototype.open = function (method, url, async, username, password) {
|
|
455
|
+
this._o11y = {
|
|
456
|
+
method,
|
|
457
|
+
url: url === null || url === void 0 ? void 0 : url.toString()
|
|
458
|
+
};
|
|
459
|
+
Tracing._originalXhrOpen.call(this, method, url, async, username, password);
|
|
460
|
+
};
|
|
409
461
|
Tracing._originalXhr.prototype.send = function (...args) {
|
|
410
462
|
let activity;
|
|
411
463
|
try {
|
|
412
464
|
tasker === null || tasker === void 0 ? void 0 : tasker.add();
|
|
413
465
|
const xhr = this;
|
|
414
|
-
xhr.
|
|
466
|
+
xhr._o11y = xhr._o11y || {};
|
|
467
|
+
xhr._o11y.activity = activity = instr.startActivity(activityName || defaultActivityNameForXhrSend);
|
|
415
468
|
if (useTracing) {
|
|
416
|
-
const
|
|
417
|
-
Object.entries(
|
|
469
|
+
const traceHeaders = Tracing._getTraceHeaders(activity, options, xhr._o11y.method, xhr._o11y.url);
|
|
470
|
+
Object.entries(traceHeaders).forEach((entry) => {
|
|
418
471
|
xhr.setRequestHeader(entry[0], entry[1]);
|
|
419
472
|
});
|
|
420
473
|
}
|
|
@@ -438,13 +491,14 @@ class Tracing {
|
|
|
438
491
|
construct(target) {
|
|
439
492
|
const newXhr = new target();
|
|
440
493
|
newXhr.addEventListener('load', () => {
|
|
441
|
-
var _a;
|
|
442
|
-
(_a = newXhr.
|
|
494
|
+
var _a, _b;
|
|
495
|
+
(_b = (_a = newXhr._o11y) === null || _a === void 0 ? void 0 : _a.activity) === null || _b === void 0 ? void 0 : _b.stop();
|
|
443
496
|
tasker === null || tasker === void 0 ? void 0 : tasker.done();
|
|
444
497
|
});
|
|
445
498
|
newXhr.addEventListener('error', (__err) => {
|
|
499
|
+
var _a;
|
|
446
500
|
const error = new Error('XHR Network-Level Error');
|
|
447
|
-
const activity = newXhr.
|
|
501
|
+
const activity = (_a = newXhr._o11y) === null || _a === void 0 ? void 0 : _a.activity;
|
|
448
502
|
if (activity) {
|
|
449
503
|
if (logErrors) {
|
|
450
504
|
activity.error(error);
|
|
@@ -457,8 +511,8 @@ class Tracing {
|
|
|
457
511
|
tasker === null || tasker === void 0 ? void 0 : tasker.done();
|
|
458
512
|
});
|
|
459
513
|
newXhr.addEventListener('abort', () => {
|
|
460
|
-
|
|
461
|
-
|
|
514
|
+
var _a, _b;
|
|
515
|
+
(_b = (_a = newXhr._o11y) === null || _a === void 0 ? void 0 : _a.activity) === null || _b === void 0 ? void 0 : _b.discard();
|
|
462
516
|
tasker === null || tasker === void 0 ? void 0 : tasker.done();
|
|
463
517
|
});
|
|
464
518
|
return newXhr;
|
|
@@ -469,8 +523,8 @@ class Tracing {
|
|
|
469
523
|
networkInstrumentation(options) {
|
|
470
524
|
var _a;
|
|
471
525
|
utility.requireArgument(options, 'options', ['boolean', 'object']);
|
|
526
|
+
this._disableNetworkInstrumentation();
|
|
472
527
|
if (options) {
|
|
473
|
-
this._disableNetworkInstrumentation();
|
|
474
528
|
const tracingOptions = typeof options === 'object' ? options : {};
|
|
475
529
|
let tasker = undefined;
|
|
476
530
|
if (utility.definedValueOrDefault(tracingOptions.useTasker, true)) {
|
|
@@ -478,13 +532,14 @@ class Tracing {
|
|
|
478
532
|
}
|
|
479
533
|
this._enableNetworkInstrumentation(utility.definedValueOrDefault(tracingOptions.instrumentation, this._instr), utility.definedValueOrDefault(tracingOptions.logErrors, true), tracingOptions.activityName, utility.definedValueOrDefault(tracingOptions.useTracing, true), tracingOptions.tracingHeadersOptions, tasker);
|
|
480
534
|
}
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
535
|
+
}
|
|
536
|
+
resetRequestCounter() {
|
|
537
|
+
Tracing._reqIndex = 0;
|
|
484
538
|
}
|
|
485
539
|
}
|
|
486
540
|
Tracing._global = utility.getGlobal();
|
|
487
541
|
Tracing._isNetworkInstrumentationEnabled = false;
|
|
542
|
+
Tracing._reqIndex = 0;
|
|
488
543
|
|
|
489
544
|
var TimerOverride;
|
|
490
545
|
(function (TimerOverride) {
|
|
@@ -1791,7 +1846,7 @@ class NextgenImpl {
|
|
|
1791
1846
|
this._appInstr = new AppInstrumentationImpl(this, name, options === null || options === void 0 ? void 0 : options.allowMultipleRootActivities);
|
|
1792
1847
|
this._instruments.set(name, this._appInstr);
|
|
1793
1848
|
this._isBufferingEnabled = options === null || options === void 0 ? void 0 : options.enableBuffering;
|
|
1794
|
-
const tracing = new Tracing(this.
|
|
1849
|
+
const tracing = new Tracing(this.getInstrumentation('Network'), this._idleDetector);
|
|
1795
1850
|
return {
|
|
1796
1851
|
log: this._appInstr.log.bind(this._appInstr),
|
|
1797
1852
|
error: this._appInstr.error.bind(this._appInstr),
|
|
@@ -2043,7 +2098,7 @@ class ConsoleCollector {
|
|
|
2043
2098
|
}
|
|
2044
2099
|
}
|
|
2045
2100
|
|
|
2046
|
-
const version = '244.
|
|
2101
|
+
const version = '244.7.0';
|
|
2047
2102
|
|
|
2048
2103
|
const idleDetector = new IdleDetectorImpl({
|
|
2049
2104
|
logThreshold: 300,
|