UNPKG

@grafana/faro-web-tracing

Version:
27 lines 1.04 kB
import { XMLHttpRequestInstrumentation } from '@opentelemetry/instrumentation-xml-http-request'; import { faro, getUrlFromResource } from '@grafana/faro-web-sdk'; export class FaroXhrInstrumentation extends XMLHttpRequestInstrumentation { constructor(config = {}) { super(config); const self = this; this.parentCreateSpan = self._createSpan.bind(this); } // Patching the parent's private method to handle url type string or URL _patchOpen() { return (original) => { const plugin = this; return function patchOpen(...args) { try { const method = args[0]; let url = getUrlFromResource(args[1]); plugin.parentCreateSpan(this, url, method); } catch (error) { faro.internalLogger.error(error); } return original.apply(this, args); }; }; } } //# sourceMappingURL=faroXhrInstrumentation.js.map