UNPKG

next

Version:

The React Framework

57 lines (56 loc) • 2.06 kB
import type { SpanId, TraceEvent, TraceState } from './types'; export declare enum SpanStatus { Started = "started", Stopped = "stopped" } interface Attributes { [key: string]: unknown; } export declare class Span { private name; private id; private parentId?; private attrs; private status; private now; private _start; constructor({ name, parentId, attrs, startTime, wallStartTimeMs, }: { name: string; parentId?: SpanId; startTime?: bigint; wallStartTimeMs?: number; attrs?: Attributes; }); stop(stopTime?: bigint): void; traceChild(name: string, attrs?: Attributes): Span; manualTraceChild(name: string, startTime?: bigint, stopTime?: bigint, attrs?: Attributes): void; getId(): number; setAttribute(key: string, value: unknown): void; traceFn<T>(fn: (span: Span) => T): T; traceAsyncFn<T>(fn: (span: Span) => T | Promise<T>): Promise<T>; } export declare const trace: (name: string, parentId?: SpanId, attrs?: { [key: string]: unknown; }) => Span; export declare const flushAllTraces: () => void; /** * Flush and release the trace file handle. Intended for tests that need to * delete the directory holding the trace afterwards. */ export declare const closeAllTraces: () => void; export declare const exportTraceState: () => TraceState; export declare const initializeTraceState: (state: TraceState) => void; export declare function getTraceEvents(): TraceEvent[]; export declare function recordTraceEvents(events: TraceEvent[]): void; export declare const clearTraceEvents: () => never[]; /** * Converts hrtime (process.hrtime.bigint()) to epoch-based nanoseconds. * * hrtime values are relative to an arbitrary point in the past, while * epoch-based times are nanoseconds since Unix epoch (Jan 1, 1970). * * This is useful when passing hrtime values to APIs that expect epoch-based times, * such as Span.manualTraceChild(). */ export declare function hrtimeToEpochNanoseconds(hrtimeValue: bigint): bigint; export {};