@opentelemetry/instrumentation-xml-http-request 0.222.0 → 0.300.0-development.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/README.md +8 -10
- package/dist/_virtual/_rolldown/runtime.cjs +23 -0
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/semconv.cjs +13 -0
- package/dist/semconv.cjs.map +1 -0
- package/dist/semconv.mjs +13 -0
- package/dist/semconv.mjs.map +1 -0
- package/dist/types.d.cts +31 -0
- package/dist/types.d.cts.map +1 -0
- package/dist/types.d.mts +31 -0
- package/dist/types.d.mts.map +1 -0
- package/dist/utils.cjs +86 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.mjs +82 -0
- package/dist/utils.mjs.map +1 -0
- package/dist/version.cjs +6 -0
- package/dist/version.cjs.map +1 -0
- package/dist/version.mjs +6 -0
- package/dist/version.mjs.map +1 -0
- package/dist/xhr.cjs +345 -0
- package/dist/xhr.cjs.map +1 -0
- package/dist/xhr.d.cts +133 -0
- package/dist/xhr.d.cts.map +1 -0
- package/dist/xhr.d.mts +133 -0
- package/dist/xhr.d.mts.map +1 -0
- package/dist/xhr.mjs +343 -0
- package/dist/xhr.mjs.map +1 -0
- package/package.json +34 -31
- package/build/esm/enums/EventNames.d.ts +0 -9
- package/build/esm/enums/EventNames.js +0 -14
- package/build/esm/enums/EventNames.js.map +0 -1
- package/build/esm/index.d.ts +0 -3
- package/build/esm/index.js +0 -6
- package/build/esm/index.js.map +0 -1
- package/build/esm/semconv.d.ts +0 -9
- package/build/esm/semconv.js +0 -18
- package/build/esm/semconv.js.map +0 -1
- package/build/esm/types.d.ts +0 -29
- package/build/esm/types.js +0 -6
- package/build/esm/types.js.map +0 -1
- package/build/esm/utils.d.ts +0 -14
- package/build/esm/utils.js +0 -118
- package/build/esm/utils.js.map +0 -1
- package/build/esm/version.d.ts +0 -2
- package/build/esm/version.js +0 -7
- package/build/esm/version.js.map +0 -1
- package/build/esm/xhr.d.ts +0 -131
- package/build/esm/xhr.js +0 -415
- package/build/esm/xhr.js.map +0 -1
- package/build/esnext/enums/EventNames.d.ts +0 -9
- package/build/esnext/enums/EventNames.js +0 -14
- package/build/esnext/enums/EventNames.js.map +0 -1
- package/build/esnext/index.d.ts +0 -3
- package/build/esnext/index.js +0 -6
- package/build/esnext/index.js.map +0 -1
- package/build/esnext/semconv.d.ts +0 -9
- package/build/esnext/semconv.js +0 -18
- package/build/esnext/semconv.js.map +0 -1
- package/build/esnext/types.d.ts +0 -29
- package/build/esnext/types.js +0 -6
- package/build/esnext/types.js.map +0 -1
- package/build/esnext/utils.d.ts +0 -14
- package/build/esnext/utils.js +0 -118
- package/build/esnext/utils.js.map +0 -1
- package/build/esnext/version.d.ts +0 -2
- package/build/esnext/version.js +0 -7
- package/build/esnext/version.js.map +0 -1
- package/build/esnext/xhr.d.ts +0 -131
- package/build/esnext/xhr.js +0 -415
- package/build/esnext/xhr.js.map +0 -1
- package/build/src/enums/EventNames.d.ts +0 -9
- package/build/src/enums/EventNames.js +0 -17
- package/build/src/enums/EventNames.js.map +0 -1
- package/build/src/index.d.ts +0 -3
- package/build/src/index.js +0 -10
- package/build/src/index.js.map +0 -1
- package/build/src/semconv.d.ts +0 -9
- package/build/src/semconv.js +0 -21
- package/build/src/semconv.js.map +0 -1
- package/build/src/types.d.ts +0 -29
- package/build/src/types.js +0 -7
- package/build/src/types.js.map +0 -1
- package/build/src/utils.d.ts +0 -14
- package/build/src/utils.js +0 -124
- package/build/src/utils.js.map +0 -1
- package/build/src/version.d.ts +0 -2
- package/build/src/version.js +0 -10
- package/build/src/version.js.map +0 -1
- package/build/src/xhr.d.ts +0 -131
- package/build/src/xhr.js +0 -419
- package/build/src/xhr.js.map +0 -1
package/build/esnext/xhr.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"xhr.js","sourceRoot":"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G,IAAI,CAAC;SACxB;QAAC,OAAO,GAAG,EAAE;YACZ,0CAA0C;YAC1C,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,OAAO,CAAC,cAAc,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;YAC/C,IAAI,CAAC,KAAK,CAAC,IAAI,CACb,kFAAkF;gBAChF,qFAAqF,EACvF,GAAG,CACJ,CAAC;SACH;IACH,CAAC;IAED;;OAEG;IACM,OAAO;QACd,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE;YACpB,OAAO;SACR;QACD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;QACxB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,IAAI,OAAO,EAA0B,CAAC;QACrD,IAAI,CAAC,cAAc,GAAG,IAAI,OAAO,EAA6B,CAAC;IACjE,CAAC;CACF","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport * as api from '@opentelemetry/api';\nimport type { InstrumentationConfig } from '@opentelemetry/instrumentation';\nimport {\n InstrumentationBase,\n safeExecuteInTheMiddle,\n} from '@opentelemetry/instrumentation';\nimport { hrTime, isUrlIgnored, otperformance } from '@opentelemetry/core';\nimport {\n addSpanNetworkEvents,\n getResource,\n PerformanceTimingNames as PTN,\n shouldPropagateTraceHeaders,\n parseUrl,\n} from '@opentelemetry/sdk-trace-web';\nimport {\n ATTR_ERROR_TYPE,\n ATTR_HTTP_REQUEST_METHOD,\n ATTR_HTTP_REQUEST_METHOD_ORIGINAL,\n ATTR_HTTP_RESPONSE_STATUS_CODE,\n ATTR_SERVER_ADDRESS,\n ATTR_SERVER_PORT,\n ATTR_URL_FULL,\n} from '@opentelemetry/semantic-conventions';\nimport { ATTR_HTTP_REQUEST_BODY_SIZE } from './semconv';\nimport { EventNames } from './enums/EventNames';\nimport type {\n OpenFunction,\n PropagateTraceHeaderCorsUrls,\n SendFunction,\n XhrMem,\n} from './types';\nimport {\n normalizeHttpRequestMethod,\n serverPortFromUrl,\n getXHRBodyLength,\n} from './utils';\nimport { VERSION } from './version';\n\n// how long to wait for observer to collect information about resources\n// this is needed as event \"load\" is called before observer\n// hard to say how long it should really wait, seems like 300ms is\n// safe enough\nconst OBSERVER_WAIT_TIME_MS = 300;\n\nexport type XHRCustomAttributeFunction = (\n span: api.Span,\n xhr: XMLHttpRequest\n) => void;\n\n/**\n * XMLHttpRequest config\n */\nexport interface XMLHttpRequestInstrumentationConfig\n extends InstrumentationConfig {\n /**\n * The number of timing resources is limited, after the limit\n * (chrome 250, safari 150) the information is not collected anymore.\n * The only way to prevent that is to regularly clean the resources\n * whenever it is possible. This is needed only when PerformanceObserver\n * is not available\n */\n clearTimingResources?: boolean;\n /** URLs which should include trace headers when origin doesn't match */\n propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls;\n /**\n * URLs that partially match any regex in ignoreUrls will not be traced.\n * In addition, URLs that are _exact matches_ of strings in ignoreUrls will\n * also not be traced.\n */\n ignoreUrls?: Array<string | RegExp>;\n /** Function for adding custom attributes on the span */\n applyCustomAttributesOnSpan?: XHRCustomAttributeFunction;\n /** Ignore adding network events as span events */\n ignoreNetworkEvents?: boolean;\n /** Measure outgoing request size */\n measureRequestSize?: boolean;\n}\n\n/**\n * This class represents a XMLHttpRequest plugin for auto instrumentation\n */\nexport class XMLHttpRequestInstrumentation extends InstrumentationBase<XMLHttpRequestInstrumentationConfig> {\n readonly component: string = 'xml-http-request';\n readonly version: string = VERSION;\n moduleName = this.component;\n\n private _tasksCount = 0;\n private _xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n private _usedResources = new WeakSet<PerformanceResourceTiming>();\n\n // Note: Intentionally *not* using `_enabled` as the field name to avoid\n // any possible confusion with the `_enabled` field used on the *Node.js*\n // InstrumentationBase class.\n // Also not initializing the fields to `false` because the base class\n // constructor already calls `enable` modifying their values and it will\n // set the instrumentations in a bad state (enabled, patched but with flags set to false)\n declare private _isEnabled: boolean;\n declare private _isXhrPatched: boolean;\n\n constructor(config: XMLHttpRequestInstrumentationConfig = {}) {\n super('@opentelemetry/instrumentation-xml-http-request', VERSION, config);\n }\n\n init() {}\n\n /**\n * Adds custom headers to XMLHttpRequest\n * @param xhr\n * @param spanUrl\n * @private\n */\n private _addHeaders(xhr: XMLHttpRequest, spanUrl: string) {\n const url = parseUrl(spanUrl).href;\n if (\n !shouldPropagateTraceHeaders(\n url,\n this.getConfig().propagateTraceHeaderCorsUrls\n )\n ) {\n const headers: Partial<Record<string, unknown>> = {};\n api.propagation.inject(api.context.active(), headers);\n if (Object.keys(headers).length > 0) {\n this._diag.debug('headers inject skipped due to CORS policy');\n }\n return;\n }\n const headers: { [key: string]: unknown } = {};\n api.propagation.inject(api.context.active(), headers);\n Object.keys(headers).forEach(key => {\n xhr.setRequestHeader(key, String(headers[key]));\n });\n }\n\n /**\n * Add cors pre flight child span\n * @param span\n * @param corsPreFlightRequest\n * @private\n */\n private _addChildSpan(\n span: api.Span,\n corsPreFlightRequest: PerformanceResourceTiming\n ): void {\n api.context.with(api.trace.setSpan(api.context.active(), span), () => {\n const childSpan = this.tracer.startSpan('CORS Preflight', {\n startTime: corsPreFlightRequest[PTN.FETCH_START],\n });\n addSpanNetworkEvents(\n childSpan,\n corsPreFlightRequest,\n this.getConfig().ignoreNetworkEvents,\n undefined,\n true\n );\n childSpan.end(corsPreFlightRequest[PTN.RESPONSE_END]);\n });\n }\n\n /**\n * Add attributes when span is going to end\n * @param span\n * @param xhr\n * @private\n */\n _addFinalSpanAttributes(span: api.Span, xhrMem: XhrMem) {\n if (xhrMem.status) {\n // Intentionally exclude status=0, because XHR uses 0 for before a\n // response is received and semconv says to only add the attribute if\n // received a response.\n span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, xhrMem.status);\n }\n }\n\n private _applyAttributesAfterXHR(span: api.Span, xhr: XMLHttpRequest) {\n const applyCustomAttributesOnSpan =\n this.getConfig().applyCustomAttributesOnSpan;\n if (typeof applyCustomAttributesOnSpan === 'function') {\n safeExecuteInTheMiddle(\n () => applyCustomAttributesOnSpan(span, xhr),\n error => {\n if (!error) {\n return;\n }\n\n this._diag.error('applyCustomAttributesOnSpan', error);\n },\n true\n );\n }\n }\n\n /**\n * will collect information about all resources created\n * between \"send\" and \"end\" with additional waiting for main resource\n * @param xhr\n * @param spanUrl\n * @private\n */\n private _addResourceObserver(xhr: XMLHttpRequest, spanUrl: string) {\n const xhrMem = this._xhrMem.get(xhr);\n if (\n !xhrMem ||\n typeof PerformanceObserver !== 'function' ||\n typeof PerformanceResourceTiming !== 'function'\n ) {\n return;\n }\n xhrMem.createdResources = {\n observer: new PerformanceObserver(list => {\n const entries = list.getEntries() as PerformanceResourceTiming[];\n const parsedUrl = parseUrl(spanUrl);\n\n entries.forEach(entry => {\n if (\n entry.initiatorType === 'xmlhttprequest' &&\n entry.name === parsedUrl.href\n ) {\n if (xhrMem.createdResources) {\n xhrMem.createdResources.entries.push(entry);\n }\n }\n });\n }),\n entries: [],\n };\n xhrMem.createdResources.observer.observe({\n entryTypes: ['resource'],\n });\n }\n\n /**\n * Clears the resource timings and all resources assigned with spans\n * when {@link XMLHttpRequestInstrumentationConfig.clearTimingResources} is\n * set to true (default false)\n * @private\n */\n private _clearResources() {\n if (this._tasksCount === 0 && this.getConfig().clearTimingResources) {\n (otperformance as unknown as Performance).clearResourceTimings();\n this._xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n this._usedResources = new WeakSet<PerformanceResourceTiming>();\n }\n }\n\n /**\n * Finds appropriate resource and add network events to the span\n * @param span\n */\n private _findResourceAndAddNetworkEvents(\n xhrMem: XhrMem,\n span: api.Span,\n spanUrl?: string,\n startTime?: api.HrTime,\n endTime?: api.HrTime\n ): void {\n if (!spanUrl || !startTime || !endTime || !xhrMem.createdResources) {\n return;\n }\n let resources: PerformanceResourceTiming[] =\n xhrMem.createdResources.entries;\n\n if (!resources || !resources.length) {\n // fallback - either Observer is not available or it took longer\n // then OBSERVER_WAIT_TIME_MS and observer didn't collect enough\n // information\n // ts thinks this is the perf_hooks module, but it is the browser performance api\n resources = (otperformance as unknown as Performance).getEntriesByType(\n 'resource'\n ) as PerformanceResourceTiming[];\n }\n\n const resource = getResource(\n parseUrl(spanUrl).href,\n startTime,\n endTime,\n resources,\n this._usedResources\n );\n\n if (resource.mainRequest) {\n const mainRequest = resource.mainRequest;\n this._markResourceAsUsed(mainRequest);\n\n const corsPreFlightRequest = resource.corsPreFlightRequest;\n if (corsPreFlightRequest) {\n this._addChildSpan(span, corsPreFlightRequest);\n this._markResourceAsUsed(corsPreFlightRequest);\n }\n addSpanNetworkEvents(\n span,\n mainRequest,\n this.getConfig().ignoreNetworkEvents,\n undefined,\n true\n );\n }\n }\n\n /**\n * Removes the previous information about span.\n * This might happened when the same xhr is used again.\n * @param xhr\n * @private\n */\n private _cleanPreviousSpanInformation(xhr: XMLHttpRequest) {\n const xhrMem = this._xhrMem.get(xhr);\n if (xhrMem) {\n const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;\n if (callbackToRemoveEvents) {\n callbackToRemoveEvents();\n }\n this._xhrMem.delete(xhr);\n }\n }\n\n /**\n * Creates a new span when method \"open\" is called\n * @param xhr\n * @param url\n * @param method\n * @private\n */\n private _createSpan(\n xhr: XMLHttpRequest,\n url: string,\n method: string\n ): api.Span | undefined {\n const parsedUrl = parseUrl(url);\n if (isUrlIgnored(parsedUrl.href, this.getConfig().ignoreUrls)) {\n this._diag.debug('ignoring span as url matches ignored url');\n return;\n }\n const attributes = {} as api.Attributes;\n const origMethod = method;\n const normMethod = normalizeHttpRequestMethod(method);\n const name = normMethod;\n\n attributes[ATTR_HTTP_REQUEST_METHOD] = normMethod;\n if (normMethod !== origMethod) {\n attributes[ATTR_HTTP_REQUEST_METHOD_ORIGINAL] = origMethod;\n }\n attributes[ATTR_URL_FULL] = parsedUrl.toString();\n attributes[ATTR_SERVER_ADDRESS] = parsedUrl.hostname;\n const serverPort = serverPortFromUrl(parsedUrl);\n if (serverPort) {\n attributes[ATTR_SERVER_PORT] = serverPort;\n }\n\n const currentSpan = this.tracer.startSpan(name, {\n kind: api.SpanKind.CLIENT,\n attributes,\n });\n\n currentSpan.addEvent(EventNames.METHOD_OPEN);\n\n this._cleanPreviousSpanInformation(xhr);\n\n this._xhrMem.set(xhr, {\n span: currentSpan,\n spanUrl: url,\n });\n\n return currentSpan;\n }\n\n /**\n * Marks certain [resource]{@link PerformanceResourceTiming} when information\n * from this is used to add events to span.\n * This is done to avoid reusing the same resource again for next span\n * @param resource\n * @private\n */\n private _markResourceAsUsed(resource: PerformanceResourceTiming) {\n this._usedResources.add(resource);\n }\n\n /**\n * Patches the method open\n * @private\n */\n protected _patchOpen() {\n return (original: OpenFunction): OpenFunction => {\n const plugin = this;\n return function patchOpen(this: XMLHttpRequest, ...args): void {\n if (!plugin._isEnabled) {\n return original.apply(this, args);\n }\n const method: string = args[0];\n const url: string = args[1];\n plugin._createSpan(this, url, method);\n\n return original.apply(this, args);\n };\n };\n }\n\n /**\n * Patches the method send\n * @private\n */\n protected _patchSend() {\n const plugin = this;\n\n function endSpanTimeout(\n eventName: string,\n xhrMem: XhrMem,\n performanceEndTime: api.HrTime,\n endTime: number\n ) {\n const callbackToRemoveEvents = xhrMem.callbackToRemoveEvents;\n\n if (typeof callbackToRemoveEvents === 'function') {\n callbackToRemoveEvents();\n }\n\n const { span, spanUrl, sendStartTime } = xhrMem;\n\n if (span) {\n plugin._findResourceAndAddNetworkEvents(\n xhrMem,\n span,\n spanUrl,\n sendStartTime,\n performanceEndTime\n );\n span.addEvent(eventName, endTime);\n plugin._addFinalSpanAttributes(span, xhrMem);\n span.end(endTime);\n plugin._tasksCount--;\n }\n plugin._clearResources();\n }\n\n function endSpan(\n eventName: string,\n xhr: XMLHttpRequest,\n isError: boolean,\n errorType?: string\n ) {\n const xhrMem = plugin._xhrMem.get(xhr);\n if (!xhrMem) {\n return;\n }\n xhrMem.status = xhr.status;\n xhrMem.statusText = xhr.statusText;\n plugin._xhrMem.delete(xhr);\n\n if (xhrMem.span) {\n const span = xhrMem.span;\n plugin._applyAttributesAfterXHR(span, xhr);\n\n if (isError) {\n if (errorType) {\n span.setStatus({\n code: api.SpanStatusCode.ERROR,\n message: errorType,\n });\n span.setAttribute(ATTR_ERROR_TYPE, errorType);\n }\n } else if (xhrMem.status && xhrMem.status >= 400) {\n span.setStatus({ code: api.SpanStatusCode.ERROR });\n span.setAttribute(ATTR_ERROR_TYPE, String(xhrMem.status));\n }\n }\n\n const performanceEndTime = hrTime();\n const endTime = Date.now();\n\n // the timeout is needed as observer doesn't have yet information\n // when event \"load\" is called. Also the time may differ depends on\n // browser and speed of computer\n setTimeout(() => {\n endSpanTimeout(eventName, xhrMem, performanceEndTime, endTime);\n }, OBSERVER_WAIT_TIME_MS);\n }\n\n function onError(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_ERROR, this, true, 'error');\n }\n\n function onAbort(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_ABORT, this, false);\n }\n\n function onTimeout(this: XMLHttpRequest) {\n endSpan(EventNames.EVENT_TIMEOUT, this, true, 'timeout');\n }\n\n function onLoad(this: XMLHttpRequest) {\n if (this.status < 299) {\n endSpan(EventNames.EVENT_LOAD, this, false);\n } else {\n endSpan(EventNames.EVENT_ERROR, this, false);\n }\n }\n\n function unregister(xhr: XMLHttpRequest) {\n xhr.removeEventListener('abort', onAbort);\n xhr.removeEventListener('error', onError);\n xhr.removeEventListener('load', onLoad);\n xhr.removeEventListener('timeout', onTimeout);\n const xhrMem = plugin._xhrMem.get(xhr);\n if (xhrMem) {\n xhrMem.callbackToRemoveEvents = undefined;\n }\n }\n\n return (original: SendFunction): SendFunction => {\n return function patchSend(this: XMLHttpRequest, ...args): void {\n if (!plugin._isEnabled) {\n return original.apply(this, args);\n }\n const xhrMem = plugin._xhrMem.get(this);\n if (!xhrMem) {\n return original.apply(this, args);\n }\n const currentSpan = xhrMem.span;\n const spanUrl = xhrMem.spanUrl;\n\n if (currentSpan && spanUrl) {\n if (plugin.getConfig().measureRequestSize && args?.[0]) {\n const body = args[0];\n const bodyLength = getXHRBodyLength(body);\n if (bodyLength !== undefined) {\n currentSpan.setAttribute(ATTR_HTTP_REQUEST_BODY_SIZE, bodyLength);\n }\n }\n\n api.context.with(\n api.trace.setSpan(api.context.active(), currentSpan),\n () => {\n plugin._tasksCount++;\n xhrMem.sendStartTime = hrTime();\n currentSpan.addEvent(EventNames.METHOD_SEND);\n\n this.addEventListener('abort', onAbort);\n this.addEventListener('error', onError);\n this.addEventListener('load', onLoad);\n this.addEventListener('timeout', onTimeout);\n\n xhrMem.callbackToRemoveEvents = () => {\n unregister(this);\n if (xhrMem.createdResources) {\n xhrMem.createdResources.observer.disconnect();\n }\n };\n plugin._addHeaders(this, spanUrl);\n plugin._addResourceObserver(this, spanUrl);\n }\n );\n }\n return original.apply(this, args);\n };\n };\n }\n\n /**\n * implements enable function\n */\n override enable() {\n if (this._isEnabled) {\n return;\n }\n if (this._isXhrPatched) {\n this._diag.debug(\n 'reactivating existing patch on',\n this.moduleName,\n this.version\n );\n this._isEnabled = true;\n return;\n }\n\n try {\n this._diag.debug('applying patch to', this.moduleName, this.version);\n this._wrap(XMLHttpRequest.prototype, 'open', this._patchOpen());\n this._wrap(XMLHttpRequest.prototype, 'send', this._patchSend());\n this._isXhrPatched = true;\n this._isEnabled = true;\n } catch (err) {\n // make sure there is no wrapped functions\n this._unwrap(XMLHttpRequest.prototype, 'open');\n this._unwrap(XMLHttpRequest.prototype, 'send');\n this._diag.warn(\n 'Failed to patch globalThis.XMLHttpRequest; instrumentation will not be enabled. ' +\n 'Another script may have locked globalThis.XMLHttpRequest via Object.defineProperty.',\n err\n );\n }\n }\n\n /**\n * implements disable function\n */\n override disable() {\n if (!this._isEnabled) {\n return;\n }\n this._isEnabled = false;\n this._tasksCount = 0;\n this._xhrMem = new WeakMap<XMLHttpRequest, XhrMem>();\n this._usedResources = new WeakSet<PerformanceResourceTiming>();\n }\n}\n"]}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright The OpenTelemetry Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.EventNames = void 0;
|
|
8
|
-
var EventNames;
|
|
9
|
-
(function (EventNames) {
|
|
10
|
-
EventNames["METHOD_OPEN"] = "open";
|
|
11
|
-
EventNames["METHOD_SEND"] = "send";
|
|
12
|
-
EventNames["EVENT_ABORT"] = "abort";
|
|
13
|
-
EventNames["EVENT_ERROR"] = "error";
|
|
14
|
-
EventNames["EVENT_LOAD"] = "loaded";
|
|
15
|
-
EventNames["EVENT_TIMEOUT"] = "timeout";
|
|
16
|
-
})(EventNames || (exports.EventNames = EventNames = {}));
|
|
17
|
-
//# sourceMappingURL=EventNames.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EventNames.js","sourceRoot":"","sources":["../../../src/enums/EventNames.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,kCAAoB,CAAA;IACpB,kCAAoB,CAAA;IACpB,mCAAqB,CAAA;IACrB,mCAAqB,CAAA;IACrB,mCAAqB,CAAA;IACrB,uCAAyB,CAAA;AAC3B,CAAC,EAPW,UAAU,0BAAV,UAAU,QAOrB","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport enum EventNames {\n METHOD_OPEN = 'open',\n METHOD_SEND = 'send',\n EVENT_ABORT = 'abort',\n EVENT_ERROR = 'error',\n EVENT_LOAD = 'loaded',\n EVENT_TIMEOUT = 'timeout',\n}\n"]}
|
package/build/src/index.d.ts
DELETED
package/build/src/index.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright The OpenTelemetry Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.XMLHttpRequestInstrumentation = void 0;
|
|
8
|
-
var xhr_1 = require("./xhr");
|
|
9
|
-
Object.defineProperty(exports, "XMLHttpRequestInstrumentation", { enumerable: true, get: function () { return xhr_1.XMLHttpRequestInstrumentation; } });
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/build/src/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,6BAAsD;AAA7C,oHAAA,6BAA6B,OAAA","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nexport { XMLHttpRequestInstrumentation } from './xhr';\nexport type {\n XHRCustomAttributeFunction,\n XMLHttpRequestInstrumentationConfig,\n} from './xhr';\n"]}
|
package/build/src/semconv.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
|
|
3
|
-
*
|
|
4
|
-
* @example 3495
|
|
5
|
-
*
|
|
6
|
-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
7
|
-
*/
|
|
8
|
-
export declare const ATTR_HTTP_REQUEST_BODY_SIZE: "http.request.body.size";
|
|
9
|
-
//# sourceMappingURL=semconv.d.ts.map
|
package/build/src/semconv.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright The OpenTelemetry Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.ATTR_HTTP_REQUEST_BODY_SIZE = void 0;
|
|
8
|
-
/*
|
|
9
|
-
* This file contains a copy of unstable semantic convention definitions
|
|
10
|
-
* used by this package.
|
|
11
|
-
* @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv
|
|
12
|
-
*/
|
|
13
|
-
/**
|
|
14
|
-
* The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.
|
|
15
|
-
*
|
|
16
|
-
* @example 3495
|
|
17
|
-
*
|
|
18
|
-
* @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.
|
|
19
|
-
*/
|
|
20
|
-
exports.ATTR_HTTP_REQUEST_BODY_SIZE = 'http.request.body.size';
|
|
21
|
-
//# sourceMappingURL=semconv.js.map
|
package/build/src/semconv.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"semconv.js","sourceRoot":"","sources":["../../src/semconv.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AACU,QAAA,2BAA2B,GAAG,wBAAiC,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n/*\n * This file contains a copy of unstable semantic convention definitions\n * used by this package.\n * @see https://github.com/open-telemetry/opentelemetry-js/tree/main/semantic-conventions#unstable-semconv\n */\n\n/**\n * The size of the request payload body in bytes. This is the number of bytes transferred excluding headers and is often, but not always, present as the [Content-Length](https://www.rfc-editor.org/rfc/rfc9110.html#field.content-length) header. For requests using transport encoding, this should be the compressed size.\n *\n * @example 3495\n *\n * @experimental This attribute is experimental and is subject to breaking changes in minor releases of `@opentelemetry/semantic-conventions`.\n */\nexport const ATTR_HTTP_REQUEST_BODY_SIZE = 'http.request.body.size' as const;\n"]}
|
package/build/src/types.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import type * as api from '@opentelemetry/api';
|
|
2
|
-
/**
|
|
3
|
-
* method "open" from XMLHttpRequest
|
|
4
|
-
*/
|
|
5
|
-
export type OpenFunction = (method: string, url: string, async?: boolean, user?: string | null, pass?: string | null) => void;
|
|
6
|
-
/**
|
|
7
|
-
* method "send" from XMLHttpRequest
|
|
8
|
-
*/
|
|
9
|
-
export type SendFunction = typeof XMLHttpRequest.prototype.send;
|
|
10
|
-
export type SendBody = string | Document | Blob | ArrayBufferView | ArrayBuffer | FormData | URLSearchParams | ReadableStream<Uint8Array> | null;
|
|
11
|
-
/**
|
|
12
|
-
* interface to store information in weak map about spans, resources and
|
|
13
|
-
* callbacks
|
|
14
|
-
*/
|
|
15
|
-
export interface XhrMem {
|
|
16
|
-
status?: number;
|
|
17
|
-
statusText?: string;
|
|
18
|
-
span: api.Span;
|
|
19
|
-
spanUrl?: string;
|
|
20
|
-
sendStartTime?: api.HrTime;
|
|
21
|
-
createdResources?: {
|
|
22
|
-
observer: PerformanceObserver;
|
|
23
|
-
entries: PerformanceResourceTiming[];
|
|
24
|
-
};
|
|
25
|
-
callbackToRemoveEvents?: () => void;
|
|
26
|
-
}
|
|
27
|
-
export type PropagateTraceHeaderCorsUrl = string | RegExp;
|
|
28
|
-
export type PropagateTraceHeaderCorsUrls = PropagateTraceHeaderCorsUrl | PropagateTraceHeaderCorsUrl[];
|
|
29
|
-
//# sourceMappingURL=types.d.ts.map
|
package/build/src/types.js
DELETED
package/build/src/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";AAAA;;;GAGG","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\nimport type * as api from '@opentelemetry/api';\n\n/**\n * method \"open\" from XMLHttpRequest\n */\nexport type OpenFunction = (\n method: string,\n url: string,\n async?: boolean,\n user?: string | null,\n pass?: string | null\n) => void;\n\n/**\n * method \"send\" from XMLHttpRequest\n */\nexport type SendFunction = typeof XMLHttpRequest.prototype.send;\n\nexport type SendBody =\n | string\n | Document\n | Blob\n | ArrayBufferView\n | ArrayBuffer\n | FormData\n | URLSearchParams\n | ReadableStream<Uint8Array>\n | null;\n\n/**\n * interface to store information in weak map about spans, resources and\n * callbacks\n */\nexport interface XhrMem {\n status?: number;\n statusText?: string;\n // span assigned to xhr\n span: api.Span;\n // span url - not available on types.Span\n spanUrl?: string;\n // startTime of send function - used to filter cors preflight requests\n sendStartTime?: api.HrTime;\n // resources created between send and end plus some additional timeout\n createdResources?: {\n observer: PerformanceObserver;\n entries: PerformanceResourceTiming[];\n };\n // callback to remove events from xhr once the span ends\n callbackToRemoveEvents?: () => void;\n}\n\nexport type PropagateTraceHeaderCorsUrl = string | RegExp;\n\nexport type PropagateTraceHeaderCorsUrls =\n | PropagateTraceHeaderCorsUrl\n | PropagateTraceHeaderCorsUrl[];\n"]}
|
package/build/src/utils.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { URLLike } from '@opentelemetry/sdk-trace-web';
|
|
2
|
-
/**
|
|
3
|
-
* Helper function to determine payload content length for XHR requests
|
|
4
|
-
* @param body
|
|
5
|
-
* @returns content length
|
|
6
|
-
*/
|
|
7
|
-
export declare function getXHRBodyLength(body: Document | XMLHttpRequestBodyInit): number | undefined;
|
|
8
|
-
/**
|
|
9
|
-
* Normalize an HTTP request method string per `http.request.method` spec
|
|
10
|
-
* https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#http-client-span
|
|
11
|
-
*/
|
|
12
|
-
export declare function normalizeHttpRequestMethod(method: string): string;
|
|
13
|
-
export declare function serverPortFromUrl(url: URLLike): number | undefined;
|
|
14
|
-
//# sourceMappingURL=utils.d.ts.map
|
package/build/src/utils.js
DELETED
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright The OpenTelemetry Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.serverPortFromUrl = exports.normalizeHttpRequestMethod = exports.getXHRBodyLength = void 0;
|
|
8
|
-
// Much of the logic here overlaps with the same utils file in opentelemetry-instrumentation-fetch
|
|
9
|
-
// These may be unified in the future.
|
|
10
|
-
const api = require("@opentelemetry/api");
|
|
11
|
-
const core_1 = require("@opentelemetry/core");
|
|
12
|
-
const DIAG_LOGGER = api.diag.createComponentLogger({
|
|
13
|
-
namespace: '@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils',
|
|
14
|
-
});
|
|
15
|
-
function isDocument(value) {
|
|
16
|
-
return typeof Document !== 'undefined' && value instanceof Document;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Helper function to determine payload content length for XHR requests
|
|
20
|
-
* @param body
|
|
21
|
-
* @returns content length
|
|
22
|
-
*/
|
|
23
|
-
function getXHRBodyLength(body) {
|
|
24
|
-
if (isDocument(body)) {
|
|
25
|
-
return new XMLSerializer().serializeToString(document).length;
|
|
26
|
-
}
|
|
27
|
-
// XMLHttpRequestBodyInit expands to the following:
|
|
28
|
-
if (typeof body === 'string') {
|
|
29
|
-
return getByteLength(body);
|
|
30
|
-
}
|
|
31
|
-
if (body instanceof Blob) {
|
|
32
|
-
return body.size;
|
|
33
|
-
}
|
|
34
|
-
if (body instanceof FormData) {
|
|
35
|
-
return getFormDataSize(body);
|
|
36
|
-
}
|
|
37
|
-
if (body instanceof URLSearchParams) {
|
|
38
|
-
return getByteLength(body.toString());
|
|
39
|
-
}
|
|
40
|
-
// ArrayBuffer | ArrayBufferView
|
|
41
|
-
if (body.byteLength !== undefined) {
|
|
42
|
-
return body.byteLength;
|
|
43
|
-
}
|
|
44
|
-
DIAG_LOGGER.warn('unknown body type');
|
|
45
|
-
return undefined;
|
|
46
|
-
}
|
|
47
|
-
exports.getXHRBodyLength = getXHRBodyLength;
|
|
48
|
-
const TEXT_ENCODER = new TextEncoder();
|
|
49
|
-
function getByteLength(s) {
|
|
50
|
-
return TEXT_ENCODER.encode(s).byteLength;
|
|
51
|
-
}
|
|
52
|
-
function getFormDataSize(formData) {
|
|
53
|
-
let size = 0;
|
|
54
|
-
for (const [key, value] of formData.entries()) {
|
|
55
|
-
size += key.length;
|
|
56
|
-
if (value instanceof Blob) {
|
|
57
|
-
size += value.size;
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
size += value.length;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return size;
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Normalize an HTTP request method string per `http.request.method` spec
|
|
67
|
-
* https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#http-client-span
|
|
68
|
-
*/
|
|
69
|
-
function normalizeHttpRequestMethod(method) {
|
|
70
|
-
const knownMethods = getKnownMethods();
|
|
71
|
-
const methUpper = method.toUpperCase();
|
|
72
|
-
if (methUpper in knownMethods) {
|
|
73
|
-
return methUpper;
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
return '_OTHER';
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
exports.normalizeHttpRequestMethod = normalizeHttpRequestMethod;
|
|
80
|
-
const DEFAULT_KNOWN_METHODS = {
|
|
81
|
-
CONNECT: true,
|
|
82
|
-
DELETE: true,
|
|
83
|
-
GET: true,
|
|
84
|
-
HEAD: true,
|
|
85
|
-
OPTIONS: true,
|
|
86
|
-
PATCH: true,
|
|
87
|
-
POST: true,
|
|
88
|
-
PUT: true,
|
|
89
|
-
TRACE: true,
|
|
90
|
-
// QUERY from https://datatracker.ietf.org/doc/draft-ietf-httpbis-safe-method-w-body/
|
|
91
|
-
QUERY: true,
|
|
92
|
-
};
|
|
93
|
-
let knownMethods;
|
|
94
|
-
function getKnownMethods() {
|
|
95
|
-
if (knownMethods === undefined) {
|
|
96
|
-
const cfgMethods = (0, core_1.getStringListFromEnv)('OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS');
|
|
97
|
-
if (cfgMethods && cfgMethods.length > 0) {
|
|
98
|
-
knownMethods = {};
|
|
99
|
-
cfgMethods.forEach(m => {
|
|
100
|
-
knownMethods[m] = true;
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
else {
|
|
104
|
-
knownMethods = DEFAULT_KNOWN_METHODS;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return knownMethods;
|
|
108
|
-
}
|
|
109
|
-
const HTTP_PORT_FROM_PROTOCOL = {
|
|
110
|
-
'https:': '443',
|
|
111
|
-
'http:': '80',
|
|
112
|
-
};
|
|
113
|
-
function serverPortFromUrl(url) {
|
|
114
|
-
const serverPort = Number(url.port || HTTP_PORT_FROM_PROTOCOL[url.protocol]);
|
|
115
|
-
// Guard with `if (serverPort)` because `Number('') === 0`.
|
|
116
|
-
if (serverPort && !isNaN(serverPort)) {
|
|
117
|
-
return serverPort;
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
return undefined;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
exports.serverPortFromUrl = serverPortFromUrl;
|
|
124
|
-
//# sourceMappingURL=utils.js.map
|
package/build/src/utils.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,kGAAkG;AAClG,sCAAsC;AAEtC,0CAA0C;AAC1C,8CAA2D;AAG3D,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,CAAC,qBAAqB,CAAC;IACjD,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,QAAQ,EAAE,KAAK;IACf,OAAO,EAAE,IAAI;CACd,CAAC;AACF,SAAgB,iBAAiB,CAAC,GAAY;IAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,IAAI,uBAAuB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC7E,2DAA2D;IAC3D,IAAI,UAAU,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC,EAAE;QACpC,OAAO,UAAU,CAAC;KACnB;SAAM;QACL,OAAO,SAAS,CAAC;KAClB;AACH,CAAC;AARD,8CAQC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// Much of the logic here overlaps with the same utils file in opentelemetry-instrumentation-fetch\n// These may be unified in the future.\n\nimport * as api from '@opentelemetry/api';\nimport { getStringListFromEnv } from '@opentelemetry/core';\nimport type { URLLike } from '@opentelemetry/sdk-trace-web';\n\nconst DIAG_LOGGER = api.diag.createComponentLogger({\n namespace:\n '@opentelemetry/opentelemetry-instrumentation-xml-http-request/utils',\n});\n\nfunction isDocument(value: unknown): value is Document {\n return typeof Document !== 'undefined' && value instanceof Document;\n}\n\n/**\n * Helper function to determine payload content length for XHR requests\n * @param body\n * @returns content length\n */\nexport function getXHRBodyLength(\n body: Document | XMLHttpRequestBodyInit\n): number | undefined {\n if (isDocument(body)) {\n return new XMLSerializer().serializeToString(document).length;\n }\n\n // XMLHttpRequestBodyInit expands to the following:\n if (typeof body === 'string') {\n return getByteLength(body);\n }\n\n if (body instanceof Blob) {\n return body.size;\n }\n\n if (body instanceof FormData) {\n return getFormDataSize(body);\n }\n\n if (body instanceof URLSearchParams) {\n return getByteLength(body.toString());\n }\n\n // ArrayBuffer | ArrayBufferView\n if (body.byteLength !== undefined) {\n return body.byteLength;\n }\n\n DIAG_LOGGER.warn('unknown body type');\n return undefined;\n}\n\nconst TEXT_ENCODER = new TextEncoder();\nfunction getByteLength(s: string): number {\n return TEXT_ENCODER.encode(s).byteLength;\n}\n\nfunction getFormDataSize(formData: FormData): number {\n let size = 0;\n for (const [key, value] of formData.entries()) {\n size += key.length;\n if (value instanceof Blob) {\n size += value.size;\n } else {\n size += value.length;\n }\n }\n return size;\n}\n\n/**\n * Normalize an HTTP request method string per `http.request.method` spec\n * https://github.com/open-telemetry/semantic-conventions/blob/main/docs/http/http-spans.md#http-client-span\n */\nexport function normalizeHttpRequestMethod(method: string): string {\n const knownMethods = getKnownMethods();\n const methUpper = method.toUpperCase();\n if (methUpper in knownMethods) {\n return methUpper;\n } else {\n return '_OTHER';\n }\n}\n\nconst DEFAULT_KNOWN_METHODS = {\n CONNECT: true,\n DELETE: true,\n GET: true,\n HEAD: true,\n OPTIONS: true,\n PATCH: true,\n POST: true,\n PUT: true,\n TRACE: true,\n // QUERY from https://datatracker.ietf.org/doc/draft-ietf-httpbis-safe-method-w-body/\n QUERY: true,\n};\nlet knownMethods: { [key: string]: boolean };\nfunction getKnownMethods() {\n if (knownMethods === undefined) {\n const cfgMethods = getStringListFromEnv(\n 'OTEL_INSTRUMENTATION_HTTP_KNOWN_METHODS'\n );\n if (cfgMethods && cfgMethods.length > 0) {\n knownMethods = {};\n cfgMethods.forEach(m => {\n knownMethods[m] = true;\n });\n } else {\n knownMethods = DEFAULT_KNOWN_METHODS;\n }\n }\n return knownMethods;\n}\n\nconst HTTP_PORT_FROM_PROTOCOL: { [key: string]: string } = {\n 'https:': '443',\n 'http:': '80',\n};\nexport function serverPortFromUrl(url: URLLike): number | undefined {\n const serverPort = Number(url.port || HTTP_PORT_FROM_PROTOCOL[url.protocol]);\n // Guard with `if (serverPort)` because `Number('') === 0`.\n if (serverPort && !isNaN(serverPort)) {\n return serverPort;\n } else {\n return undefined;\n }\n}\n"]}
|
package/build/src/version.d.ts
DELETED
package/build/src/version.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
* Copyright The OpenTelemetry Authors
|
|
4
|
-
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
-
*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.VERSION = void 0;
|
|
8
|
-
// this is autogenerated file, see scripts/version-update.js
|
|
9
|
-
exports.VERSION = '0.222.0';
|
|
10
|
-
//# sourceMappingURL=version.js.map
|
package/build/src/version.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAEH,4DAA4D;AAC/C,QAAA,OAAO,GAAG,SAAS,CAAC","sourcesContent":["/*\n * Copyright The OpenTelemetry Authors\n * SPDX-License-Identifier: Apache-2.0\n */\n\n// this is autogenerated file, see scripts/version-update.js\nexport const VERSION = '0.222.0';\n"]}
|
package/build/src/xhr.d.ts
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
import * as api from '@opentelemetry/api';
|
|
2
|
-
import type { InstrumentationConfig } from '@opentelemetry/instrumentation';
|
|
3
|
-
import { InstrumentationBase } from '@opentelemetry/instrumentation';
|
|
4
|
-
import type { OpenFunction, PropagateTraceHeaderCorsUrls, SendFunction, XhrMem } from './types';
|
|
5
|
-
export type XHRCustomAttributeFunction = (span: api.Span, xhr: XMLHttpRequest) => void;
|
|
6
|
-
/**
|
|
7
|
-
* XMLHttpRequest config
|
|
8
|
-
*/
|
|
9
|
-
export interface XMLHttpRequestInstrumentationConfig extends InstrumentationConfig {
|
|
10
|
-
/**
|
|
11
|
-
* The number of timing resources is limited, after the limit
|
|
12
|
-
* (chrome 250, safari 150) the information is not collected anymore.
|
|
13
|
-
* The only way to prevent that is to regularly clean the resources
|
|
14
|
-
* whenever it is possible. This is needed only when PerformanceObserver
|
|
15
|
-
* is not available
|
|
16
|
-
*/
|
|
17
|
-
clearTimingResources?: boolean;
|
|
18
|
-
/** URLs which should include trace headers when origin doesn't match */
|
|
19
|
-
propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls;
|
|
20
|
-
/**
|
|
21
|
-
* URLs that partially match any regex in ignoreUrls will not be traced.
|
|
22
|
-
* In addition, URLs that are _exact matches_ of strings in ignoreUrls will
|
|
23
|
-
* also not be traced.
|
|
24
|
-
*/
|
|
25
|
-
ignoreUrls?: Array<string | RegExp>;
|
|
26
|
-
/** Function for adding custom attributes on the span */
|
|
27
|
-
applyCustomAttributesOnSpan?: XHRCustomAttributeFunction;
|
|
28
|
-
/** Ignore adding network events as span events */
|
|
29
|
-
ignoreNetworkEvents?: boolean;
|
|
30
|
-
/** Measure outgoing request size */
|
|
31
|
-
measureRequestSize?: boolean;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* This class represents a XMLHttpRequest plugin for auto instrumentation
|
|
35
|
-
*/
|
|
36
|
-
export declare class XMLHttpRequestInstrumentation extends InstrumentationBase<XMLHttpRequestInstrumentationConfig> {
|
|
37
|
-
readonly component: string;
|
|
38
|
-
readonly version: string;
|
|
39
|
-
moduleName: string;
|
|
40
|
-
private _tasksCount;
|
|
41
|
-
private _xhrMem;
|
|
42
|
-
private _usedResources;
|
|
43
|
-
private _isEnabled;
|
|
44
|
-
private _isXhrPatched;
|
|
45
|
-
constructor(config?: XMLHttpRequestInstrumentationConfig);
|
|
46
|
-
init(): void;
|
|
47
|
-
/**
|
|
48
|
-
* Adds custom headers to XMLHttpRequest
|
|
49
|
-
* @param xhr
|
|
50
|
-
* @param spanUrl
|
|
51
|
-
* @private
|
|
52
|
-
*/
|
|
53
|
-
private _addHeaders;
|
|
54
|
-
/**
|
|
55
|
-
* Add cors pre flight child span
|
|
56
|
-
* @param span
|
|
57
|
-
* @param corsPreFlightRequest
|
|
58
|
-
* @private
|
|
59
|
-
*/
|
|
60
|
-
private _addChildSpan;
|
|
61
|
-
/**
|
|
62
|
-
* Add attributes when span is going to end
|
|
63
|
-
* @param span
|
|
64
|
-
* @param xhr
|
|
65
|
-
* @private
|
|
66
|
-
*/
|
|
67
|
-
_addFinalSpanAttributes(span: api.Span, xhrMem: XhrMem): void;
|
|
68
|
-
private _applyAttributesAfterXHR;
|
|
69
|
-
/**
|
|
70
|
-
* will collect information about all resources created
|
|
71
|
-
* between "send" and "end" with additional waiting for main resource
|
|
72
|
-
* @param xhr
|
|
73
|
-
* @param spanUrl
|
|
74
|
-
* @private
|
|
75
|
-
*/
|
|
76
|
-
private _addResourceObserver;
|
|
77
|
-
/**
|
|
78
|
-
* Clears the resource timings and all resources assigned with spans
|
|
79
|
-
* when {@link XMLHttpRequestInstrumentationConfig.clearTimingResources} is
|
|
80
|
-
* set to true (default false)
|
|
81
|
-
* @private
|
|
82
|
-
*/
|
|
83
|
-
private _clearResources;
|
|
84
|
-
/**
|
|
85
|
-
* Finds appropriate resource and add network events to the span
|
|
86
|
-
* @param span
|
|
87
|
-
*/
|
|
88
|
-
private _findResourceAndAddNetworkEvents;
|
|
89
|
-
/**
|
|
90
|
-
* Removes the previous information about span.
|
|
91
|
-
* This might happened when the same xhr is used again.
|
|
92
|
-
* @param xhr
|
|
93
|
-
* @private
|
|
94
|
-
*/
|
|
95
|
-
private _cleanPreviousSpanInformation;
|
|
96
|
-
/**
|
|
97
|
-
* Creates a new span when method "open" is called
|
|
98
|
-
* @param xhr
|
|
99
|
-
* @param url
|
|
100
|
-
* @param method
|
|
101
|
-
* @private
|
|
102
|
-
*/
|
|
103
|
-
private _createSpan;
|
|
104
|
-
/**
|
|
105
|
-
* Marks certain [resource]{@link PerformanceResourceTiming} when information
|
|
106
|
-
* from this is used to add events to span.
|
|
107
|
-
* This is done to avoid reusing the same resource again for next span
|
|
108
|
-
* @param resource
|
|
109
|
-
* @private
|
|
110
|
-
*/
|
|
111
|
-
private _markResourceAsUsed;
|
|
112
|
-
/**
|
|
113
|
-
* Patches the method open
|
|
114
|
-
* @private
|
|
115
|
-
*/
|
|
116
|
-
protected _patchOpen(): (original: OpenFunction) => OpenFunction;
|
|
117
|
-
/**
|
|
118
|
-
* Patches the method send
|
|
119
|
-
* @private
|
|
120
|
-
*/
|
|
121
|
-
protected _patchSend(): (original: SendFunction) => SendFunction;
|
|
122
|
-
/**
|
|
123
|
-
* implements enable function
|
|
124
|
-
*/
|
|
125
|
-
enable(): void;
|
|
126
|
-
/**
|
|
127
|
-
* implements disable function
|
|
128
|
-
*/
|
|
129
|
-
disable(): void;
|
|
130
|
-
}
|
|
131
|
-
//# sourceMappingURL=xhr.d.ts.map
|