next
Version:
The React Framework
53 lines (52 loc) • 1.85 kB
TypeScript
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, }: {
name: string;
parentId?: SpanId;
startTime?: bigint;
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: (opts?: {
end: boolean;
}) => Promise<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 {};