/** * Trace Context Plugin * * Wraps a logger to automatically inject trace context (traceId, spanId) into all log entries. * Uses OpenTelemetry API to get the current active span. * * Every call shape pino accepts gets the ids: `log.info({ a }, 'msg')`, * `log.info('msg')`, `log.info('msg %s', x)` and `log.error(err)`, and so * does every logger made with `child()`. A string-only call is rewritten to * `(ids, msg, ...args)`; an Error becomes `{ err, ...ids }` with the error's * message as the line's message, which is what pino does on its own with an * Error in first position. With no active span, or a span whose context is * invalid, the call goes through exactly as written. * * @example * ```typescript * import { withTraceContext } from './plugins/traceContext' * import { createLogger } from '../logger' * * const baseLogger = createLogger({ name: 'my-service' }) * const logger = withTraceContext(baseLogger) * * // Logs will include traceId and spanId if an active span exists * logger.info({ userId: 123 }, 'User logged in') * logger.info('User logged in') * ``` */ import type pino from 'pino'; /** * Wrap a pino logger to inject trace context into all log calls * * This is a lightweight wrapper that intercepts log method calls and adds * traceId, spanId, and traceFlags from the active OTEL span. Loggers * returned by `child()` are wrapped the same way. * * @param logger - Base pino logger to wrap * @returns Wrapped logger with automatic trace context injection * * @example * ```typescript * const logger = withTraceContext(createLogger({ name: 'api' })) * logger.info({ userId: 123 }, 'User logged in') * // Output includes: { traceId: '...', spanId: '...', userId: 123, msg: 'User logged in' } * ``` */ export declare function withTraceContext(logger: pino.Logger): pino.Logger; //# sourceMappingURL=traceContext.d.ts.map