import type { LogSink } from '@cleverbrush/log'; /** * Configuration for {@link otelLogSink}. */ export interface OtelLogSinkOptions { /** * Logger name (`InstrumentationScope`) under which records are * emitted via the OTel Logs API. * * @default '@cleverbrush/otel' */ loggerName?: string; /** Optional logger version. */ loggerVersion?: string; /** * Hook for redacting / dropping properties before they become * OTel log record attributes. Return `undefined` to drop the * attribute entirely. */ sanitizeAttribute?: (key: string, value: unknown) => unknown | undefined; } /** * Creates a {@link LogSink} that forwards every event to the * OpenTelemetry Logs API. * * Maps each `LogEvent` to an OTel `LogRecord`: * - `timestamp` → nanoseconds via `Date.getTime()` × 1e6 * - `level` → `severityNumber` and `severityText` * - `renderedMessage` → `body` * - `properties` → flat attribute map (functions / symbols dropped, * nested objects JSON-stringified) * - `messageTemplate` → `cleverbrush.message_template` attribute * - `eventId` → `cleverbrush.event_id` attribute * - `exception.*` attributes when the event carries an `Error` * * Trace correlation (`traceId`, `spanId`) is filled in automatically * by the OTel SDK from the active context — typically established by * `tracingMiddleware`. * * The sink itself is per-event; for high-throughput services wrap it * with `BatchingSink` from `@cleverbrush/log`. * * Requires that `setupOtel({ ... })` has been called so the global * `LoggerProvider` is set; otherwise emissions become no-ops. * * @param options - logger name and attribute sanitization * @returns a `LogSink` that emits to the OTel Logs pipeline * * @example * ```ts * import { createLogger, consoleSink } from '@cleverbrush/log'; * import { otelLogSink } from '@cleverbrush/otel'; * * const logger = createLogger({ * minimumLevel: 'information', * sinks: [consoleSink(), otelLogSink()], * }); * ``` */ export declare function otelLogSink(options?: OtelLogSinkOptions): LogSink;