@grafana/faro-web-tracing
Version:
Faro web tracing implementation.
55 lines • 2.39 kB
JavaScript
;
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.FaroXhrInstrumentation = void 0;
var instrumentation_xml_http_request_1 = require("@opentelemetry/instrumentation-xml-http-request");
var FaroXhrInstrumentation = /** @class */ (function (_super) {
__extends(FaroXhrInstrumentation, _super);
function FaroXhrInstrumentation(config) {
if (config === void 0) { config = {}; }
var _this = _super.call(this, config) || this;
var self = _this;
_this.parentCreateSpan = self._createSpan.bind(_this);
return _this;
}
// Patching the parent's private method to handle url type string or URL
FaroXhrInstrumentation.prototype._patchOpen = function () {
var _this = this;
return function (original) {
var plugin = _this;
return function patchOpen() {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
var method = args[0];
var url = args[1];
if (isInstanceOfURL(url)) {
url = url.href;
}
plugin.parentCreateSpan(this, url, method);
return original.apply(this, args);
};
};
};
return FaroXhrInstrumentation;
}(instrumentation_xml_http_request_1.XMLHttpRequestInstrumentation));
exports.FaroXhrInstrumentation = FaroXhrInstrumentation;
function isInstanceOfURL(item) {
return item instanceof URL;
}
//# sourceMappingURL=faroXhrInstrumentation.js.map