//#region src/observe.d.ts /** * Attribute values accepted by `WorkspaceSpan.setAttribute` and the * initial `attributes` map passed to `Observer.span`. * * Restricted to scalar types so the same shape works against the * Cloudflare runtime's built-in `Span.setAttribute` and against * `@opentelemetry/api` without per-adapter coercion. */ type WorkspaceAttributeValue = boolean | number | string; /** * Initial attributes passed when a span is started. `undefined` values * are dropped — adapters do not forward them to the underlying span. * This matches the Cloudflare runtime, where `setAttribute(key, * undefined)` is a no-op. */ type WorkspaceAttributes = Readonly>; /** * Handle passed to the callback inside `Observer.span`. The only * mutating method is `setAttribute`, matching the Cloudflare * `ctx.tracing` `Span` surface. Adapters that target a richer system * may expose more on their own internal types, but the workspace * itself only ever calls these methods. */ interface WorkspaceSpan { /** * Sets a single attribute on the span. Passing `undefined` is a * no-op so callers can forward optional values directly. */ setAttribute(key: string, value: WorkspaceAttributeValue | undefined): void; } /** * Observer hook. A single `span` method that wraps a piece of work — * the adapter starts a span, runs the callback, and ends the span when * the callback's return value (or its returned promise) settles. * * The default observer is a no-op (see `noopObserver`); the workspace * uses it when the caller does not pass one. Adapters live in separate * subpaths so callers do not pay for `@opentelemetry/api` or * `cloudflare:workers` just to import the workspace. */ interface WorkspaceObserver { /** * Wraps `run` in a span named `name`, seeded with `attributes`. The * callback receives a `WorkspaceSpan` it can use to attach further * attributes once the work has produced values worth recording (byte * counts, exit codes, applied / skipped counts). * * Implementations must run `run` synchronously and return its result * (or its promise) unchanged so the wrapping is invisible to the * caller. Errors thrown by `run` must propagate. */ span(name: string, attributes: WorkspaceAttributes, run: (span: WorkspaceSpan) => Promise): Promise; } /** * Observer that does no work. Used when the caller does not pass one. * Calling `span(...)` returns the callback's promise directly, with no * extra `await` and no allocation beyond what the callback itself does. */ declare const noopObserver: WorkspaceObserver; //#endregion export { noopObserver as a, WorkspaceSpan as i, WorkspaceAttributes as n, WorkspaceObserver as r, WorkspaceAttributeValue as t }; //# sourceMappingURL=shared-DYgflRlD.d.ts.map