import type { OpenTelemetrySpan } from './no-op-telemetry'; import type { InterceptionContext, ObservabilityState } from './types'; export declare const DEFAULT_MAX_PAYLOAD_SIZE = 1024; export declare function serializePayload(input: unknown, maxSize: number): string; /** Extract error message from an unknown thrown value. */ export declare function errorMessage(error: unknown): string; /** Convert an unknown thrown value to an Error for `recordException`. */ export declare function toError(error: unknown): Error; /** Inject the traceparent header from a span's context into a headers map. */ export declare function injectSpanContext(span: OpenTelemetrySpan, headers: Map): void; export declare function applyCustomAttributes(state: ObservabilityState, span: OpenTelemetrySpan, interception: InterceptionContext): void; export declare function parentContextForWorkflow(state: ObservabilityState, workflowId: string): unknown; type SpanLifecycleState = Pick; /** * Run a sync body inside a span's lifecycle. * * On success, sets the span status to OK and invokes `onSuccess` (if * provided) before ending the span. On failure, sets the status to ERROR, * records the exception, and rethrows the original error by identity. The * span is always ended exactly once via `finally`. * * `onSuccess` runs before `span.end()` so callers can record success-only * side effects (metrics) in the same ordering they would inline. An * exception thrown from `onSuccess` is not caught: it overwrites the OK * status with an ERROR record and propagates to the caller. */ export declare function runWithSpan(state: SpanLifecycleState, span: OpenTelemetrySpan, body: () => T, onSuccess?: (result: T) => void): T; /** * Await an async body inside a span's lifecycle. * * Same semantics as {@link runWithSpan} but awaits `body` and accepts a * `T | Promise` return so call sites whose `next()` is typed as * possibly-synchronous still type-check. */ export declare function runAsyncWithSpan(state: SpanLifecycleState, span: OpenTelemetrySpan, body: () => T | Promise, onSuccess?: (result: T) => void): Promise; /** * Yield* a generator body inside a span's lifecycle. * * Same span lifecycle as {@link runWithSpan}. The helper uses `yield* body()`, * which forwards `.throw()` and `.return()` from the outer caller to the inner * generator per the ECMAScript generator-delegation contract: * * - `.throw(error)` surfaces as an exception inside `yield*`, is caught by * this helper, and is recorded on the span as an error before the span ends. * - `.return(value)` propagates as a normal completion: the helper's `finally` * ends the span, but the body is treated as cancelled — `onSuccess` does * not run and the span status is whatever was last set (typically unset). */ export declare function runGeneratorWithSpan(state: SpanLifecycleState, span: OpenTelemetrySpan, body: () => Generator, onSuccess?: (result: TReturn) => void): Generator; export {};