/** * These are the headers that are used in the trace headers, could be found in the spec * * @see https://www.w3.org/TR/trace-context/#design-overview */ export declare const TRACE_HEADER_NAME = "traceparent"; /** * These are the headers that are used in the trace headers, could be found in the spec * * @see https://www.w3.org/TR/trace-context/#design-overview */ export declare const TRACE_HEADER_STATE = "tracestate"; /** * Some tools that are useful when dealing with the values * of the trace header. Follows the W3C trace context standard. * * @see https://www.w3.org/TR/trace-context/ */ export declare class TraceHeader { readonly traceId: string; readonly parentId: string; readonly traceFlags: string; readonly traceState: Record; /** * Initializes a new instance with the provided trace identifiers and state information. * * @param {string} traceId The unique identifier for the trace * @param {string} parentId The identifier of the parent trace * @param {string} traceFlags Flags containing trace-related options * @param {TraceHeader["traceState"]} traceState The trace state information for additional trace context */ constructor(traceId: string, parentId: string, traceFlags: string, traceState: TraceHeader["traceState"]); /** * Creating a default trace id that is a random setup for both trace id and parent id * * @example * ```ts * const traceHeader = TraceHeader.fromTraceHeader(headers) || TraceHeader.default(); * ``` * * @returns {TraceHeader} A default trace header */ static default(): TraceHeader; /** * Should be able to consume a trace header from the headers of an http request * * @example * ```ts * const traceHeader = TraceHeader.fromTraceHeader(headers); * ``` * * @param {Record} headers The headers from the http request * @returns {TraceHeader | undefined} The trace header object, or nothing if not found */ static fromTraceHeader(headers: Record): TraceHeader | undefined; /** * Should be able to convert the trace header to the format that is used in the headers of an http request * * @example * ```ts * const traceHeader = TraceHeader.fromTraceHeader(headers) || TraceHeader.default(); * const headers = traceHeader.toTraceHeader(); * ``` * * @returns {{traceparent: string, tracestate: string}} The trace header in the format of a record, used in our http client */ toTraceHeader(): { readonly traceparent: `00-${string}-${string}-${string}`; readonly tracestate: string; }; /** * Should be able to create a new trace header with a new event in the trace state, * as the key of the eventName as breadcrumbs appending onto previous breadcrumbs with the - infix if exists. And the * trace parent gets updated as according to the docs * * @example * ```ts * const traceHeader = TraceHeader.fromTraceHeader(headers) || TraceHeader.default(); * const newTraceHeader = traceHeader.withEvent("newEvent"); * ``` * * @param {string} eventName The key of the new event * @returns {TraceHeader} The new trace header */ withEvent(eventName: string): TraceHeader; }