UNPKG

@grafana/faro-web-tracing

Version:
21 lines (20 loc) 1.3 kB
import { Span } from '@opentelemetry/api'; import type { FetchCustomAttributeFunction } from '@opentelemetry/instrumentation-fetch'; import type { XHRCustomAttributeFunction } from '@opentelemetry/instrumentation-xml-http-request'; export interface FetchError { status?: number; message: string; } /** * Adds HTTP status code to every span. * * The fetch instrumentation does not always set the span status to error as defined by the spec. * To work around that issue we manually set the span status. * * Issue: https://github.com/open-telemetry/opentelemetry-js/issues/3564 * Spec: https://github.com/open-telemetry/opentelemetry-specification/blob/v1.20.0/specification/trace/semantic_conventions/http.md#status */ export declare function setSpanStatusOnFetchError(span: Span, _request: Request | RequestInit, result: Response | FetchError): void; export declare function setSpanStatusOnXMLHttpRequestError(span: Span, xhr: XMLHttpRequest): void; export declare function fetchCustomAttributeFunctionWithDefaults(callback?: FetchCustomAttributeFunction): (span: Span, request: Request | RequestInit, result: Response | FetchError) => void; export declare function xhrCustomAttributeFunctionWithDefaults(callback?: XHRCustomAttributeFunction): (span: Span, xhr: XMLHttpRequest) => void;