import * as api from '@opentelemetry/api'; import type { OpenFunction, SendFunction, XhrMem } from '@opentelemetry/instrumentation-xml-http-request/build/src/types'; import type { PropagateTraceHeaderCorsUrls } from '@opentelemetry/sdk-trace-web/build/src/types'; interface XhrConfig { clearTimingResources?: boolean; ignoreUrls: Array | undefined; propagateTraceHeaderCorsUrls?: (string | RegExp)[]; networkHeadersCapture?: boolean; networkBodyCapture?: boolean; } /** * https://github.com/open-telemetry/opentelemetry-specification/blob/master/specification/trace/semantic_conventions/http.md */ export declare enum AttributeNames { COMPONENT = "component", HTTP_ERROR_NAME = "http.error_name", HTTP_STATUS_TEXT = "http.status_text" } export declare enum EventNames { EVENT_ABORT = "abort", EVENT_ERROR = "error", EVENT_LOAD = "loaded", EVENT_READY_STATE_CHANGE = "readystatechange", EVENT_TIMEOUT = "timeout", METHOD_OPEN = "open", METHOD_SEND = "send" } /** * Checks if trace headers should be propagated * @param spanUrl * @private */ export declare function shouldPropagateTraceHeaders(spanUrl: string, propagateTraceHeaderCorsUrls?: PropagateTraceHeaderCorsUrls): boolean; export declare class XMLHttpRequestInstrumentation { private _config; private _diag; private tracer; private _xhrMem; private _usedResources; private _tasksCount; constructor(config: XhrConfig); private _getConfig; /** * Removes the previous information about span. * This might happened when the same xhr is used again. * @param xhr * @private */ private _cleanPreviousSpanInformation; private _createSpan; /** * Marks certain [resource]{@link PerformanceResourceTiming} when information * from this is used to add events to span. * This is done to avoid reusing the same resource again for next span * @param resource * @private */ private _markResourceAsUsed; /** * Finds appropriate resource and add network events to the span * @param span */ private _findResourceAndAddNetworkEvents; /** * Clears the resource timings and all resources assigned with spans * when {@link XMLHttpRequestInstrumentationConfig.clearTimingResources} is * set to true (default false) * @private */ private _clearResources; /** * Adds custom headers to XMLHttpRequest * @param xhr * @param spanUrl * @private */ private _addHeaders; /** * Add cors pre flight child span * @param span * @param corsPreFlightRequest * @private */ private _addChildSpan; /** * will collect information about all resources created * between "send" and "end" with additional waiting for main resource * @param xhr * @param spanUrl * @private */ private _addResourceObserver; protected _wrap: (moduleExports: any, name: string, wrapper: any) => any; /** * Patches the method open * @private */ protected _patchOpen(): (original: OpenFunction) => OpenFunction; /** * Patches the method send * @private */ protected _patchSend(): (original: SendFunction) => SendFunction; /** * Add attributes when span is going to end * @param span * @param xhr * @param spanUrl * @private */ _addFinalSpanAttributes(span: api.Span, xhrMem: XhrMem, spanUrl?: string): void; enable(): void; } export declare function instrumentXHROriginal(config: XhrConfig): void; export declare function instrumentXHR(config: XhrConfig): void; export {}; //# sourceMappingURL=xhr.d.ts.map