tracer-component
Version:
Trace execution spans all across your application.
27 lines (26 loc) • 978 B
TypeScript
export type ITracerComponent = {
span<T>(name: string, tracedFunction: () => T, traceContext?: Omit<TraceContext, 'id' | 'data' | 'name'>): T;
getSpanId(): string;
getTrace(): Trace;
getTraceString(): string;
getTraceChild(): Trace;
getTraceChildString(): string;
getTraceState(): Readonly<TraceState | null>;
getTraceStateString(): string | undefined;
getContextData<T>(): Readonly<T | null>;
setContextData<T = any>(data: T): void;
setTraceStateProperty(key: string, value: string): void;
deleteTraceStateProperty(key: string): void;
};
export type TraceContext<T = any> = {
id: string;
name: string;
version: string;
traceId: string;
parentId: string;
traceFlags: string;
traceState?: Record<string, string>;
data: T;
};
export type Trace = Pick<TraceContext, 'traceId' | 'version' | 'parentId' | 'traceFlags'>;
export type TraceState = Required<Pick<TraceContext, 'traceState'>>['traceState'];