import type { Event } from "../event.js"; import { Level } from "../level.js"; import type { SpanAttributes } from "../span.js"; import type { ISubscriber } from "../subscriber.js"; type SpanNode = { id: symbol; attributes: SpanAttributes; }; type PendingSpanNode = SpanNode & { parent: undefined; }; type EnteredSpanNode = SpanNode & { parent: EnteredSpanNode | undefined; }; /** * The ManagedSubscriber class is a base class for subscribers which manage spans across async contexts. It exposes * an ergonomic high-level API which makes it easy to create custom subscribers. * * @example * ```ts * import { ManagedSubscriber, Event, SpanAttributes, setDefaultGlobalSubscriber } from "@bcheidemann/tracing"; * * class MySubscriber extends ManagedSubscriber { * public static init(): MySubscriber { * const subscriber = new MySubscriber(); * // Enter the new subscriber into the current async context * setDefaultGlobalSubscriber(subscriber); * return subscriber; * } * * protected onEvent(event: Event, spans: SpanAttributes[]): void { * console.log(event, spans); * } * } * ``` */ export declare abstract class ManagedSubscriber implements ISubscriber { private readonly _level; private _currentSpan; private readonly _pendingSpans; protected constructor(_level?: Level, _currentSpan?: EnteredSpanNode | undefined, _pendingSpans?: WeakMap); enabledForLevel(level: Level): boolean; enabled(_metadata: Event | SpanAttributes): boolean; newSpan(attributes: SpanAttributes): symbol; event(event: Event): void; enter(span: symbol): void; exit(span: symbol): void; record(spanId: symbol, key: string, value: unknown): void; currentSpan(): symbol | undefined; clone(): ISubscriber; runInContext(callback: (this: TThis, ...args: TArgs) => TReturn, thisArg: TThis, args: TArgs): TReturn; protected abstract onEvent(event: Event, spans: SpanAttributes[]): void; } export {}; //# sourceMappingURL=ManagedSubscriber.d.ts.map