/** Event name — array of strings, like Elixir's [:app, :component, :event] */ export type EventName = readonly string[]; /** Measurements — numeric values only (durations, counts, sizes) */ export type Measurements = Record; /** Metadata — contextual information (ids, classes, reasons) */ export type Metadata = Record; /** Handler function signature — called synchronously */ export type TelemetryHandler = (eventName: EventName, measurements: Measurements, metadata: Metadata) => void; declare class Telemetry { /** event key → set of handler entries */ private handlers; /** handler id → list of event keys it is attached to */ private handlerKeys; /** * Attach a handler to one or more event names. * Throws if a handler with the same id is already attached. */ attach(id: string, eventNames: EventName[], handler: TelemetryHandler): string; /** * Detach a previously attached handler by id. * Returns true if the handler was found and removed. */ detach(id: string): boolean; /** * Emit a telemetry event. Handlers are called synchronously. * If no handlers are attached for this event, this is a no-op (zero allocation). * Handler errors are silently caught — they never crash the actor system. */ execute(eventName: EventName, measurements: Measurements, metadata: Metadata): void; /** * Wrap a function in start/stop/exception telemetry events. * * - Emits `[...eventName, "start"]` before execution * - Emits `[...eventName, "stop"]` after success with `duration_ms` * - Emits `[...eventName, "exception"]` on error with `duration_ms` + error * * Supports both sync and async functions transparently. */ span(eventName: EventName, metadata: Metadata, fn: () => T): T; /** * Check if any handlers are attached for the given event name. * Used to gate instrumentation on hot paths (zero-cost when unattached). */ hasHandlers(eventName: EventName): boolean; /** List all attached handler ids. */ listHandlers(): string[]; /** Remove all handlers. Useful for test teardown. */ reset(): void; } /** Global telemetry singleton. */ export declare const telemetry: Telemetry; export declare const TelemetryEvents: { readonly actor: { readonly spawn: readonly ["libeam", "actor", "spawn"]; readonly stop: readonly ["libeam", "actor", "stop"]; readonly init: readonly ["libeam", "actor", "init"]; readonly handleCall: readonly ["libeam", "actor", "handle_call"]; readonly handleCast: readonly ["libeam", "actor", "handle_cast"]; }; readonly supervisor: { readonly crash: readonly ["libeam", "supervisor", "crash"]; readonly restart: readonly ["libeam", "supervisor", "restart"]; readonly maxRestarts: readonly ["libeam", "supervisor", "max_restarts"]; }; readonly mailbox: { readonly overflow: readonly ["libeam", "mailbox", "overflow"]; }; readonly genStage: { readonly subscribe: readonly ["libeam", "gen_stage", "subscribe"]; readonly cancel: readonly ["libeam", "gen_stage", "cancel"]; readonly dispatch: readonly ["libeam", "gen_stage", "dispatch"]; readonly bufferOverflow: readonly ["libeam", "gen_stage", "buffer_overflow"]; }; readonly cluster: { readonly join: readonly ["libeam", "cluster", "join"]; readonly leave: readonly ["libeam", "cluster", "leave"]; }; readonly system: { readonly shutdown: readonly ["libeam", "system", "shutdown"]; }; }; export {}; //# sourceMappingURL=telemetry.d.ts.map