import { type Span } from "@opentelemetry/api"; import type { SpanOptions } from "../types/index.js"; export declare function withSpan(options: SpanOptions, fn: (span: Span) => Promise): Promise; export declare function withClientSpan(options: Omit, fn: (span: Span) => Promise): Promise; /** * Span wrapper for streaming operations. * * Unlike {@link withSpan}, which ends the span when `fn` resolves, this * helper extends the span's lifetime until the **consumer** of the returned * iterable reaches end-of-stream (success), throws (error), or aborts. * * Required for any operation whose result is a producer (`StreamResult`, * `AsyncIterable`-returning function, etc.) — ending the span on `fn` * resolution would capture only the setup phase and report zero tokens / * meaningless duration. * * @param options Span options (name, tracer, attributes, kind). * @param fn Callback that produces the result. Must NOT depend on * the iterable being consumed before returning. * @param getIterable Selector that picks the `AsyncIterable` out of the * result for wrapping. * @param setIterable Setter that returns a new result with the iterable * replaced by the wrapped (span-lifetime-extending) * iterable. Should be a pure function — clone the * result rather than mutating in place. * * @example * ```ts * return withStreamSpan( * { name: "neurolink.provider.stream", tracer, attributes: {...} }, * async () => this.executeStreamInner(options), * (r) => r.stream, * (r, wrapped) => ({ ...r, stream: wrapped }), * ); * ``` */ export declare function withStreamSpan(options: SpanOptions, fn: (span: Span) => Promise, getIterable: (result: TResult) => AsyncIterable, setIterable: (result: TResult, wrapped: AsyncGenerator) => TResult): Promise; /** Convenience CLIENT-kind alias matching `withClientSpan`. */ export declare function withClientStreamSpan(options: Omit, fn: (span: Span) => Promise, getIterable: (result: TResult) => AsyncIterable, setIterable: (result: TResult, wrapped: AsyncGenerator) => TResult): Promise;