import { type Attributes, type Span, SpanKind } from '@opentelemetry/api'; import { type JoinPoint } from './aop'; import type { Plugin } from './app'; import type { Context as HttpContext } from './http'; /** Options for the {@link otel} plugin. Convention-first: everything defaults. */ export interface OtelOptions { /** Tracer name (default `"turnover"`) passed to `trace.getTracer`. */ tracerName?: string; /** Tracer version passed to `trace.getTracer`; surfaces in the instrumentation scope of emitted spans. */ tracerVersion?: string; /** Return `true` to skip tracing a request (e.g. health checks). */ ignore?: (ctx: HttpContext) => boolean; /** Add extra attributes to the server span (called after the defaults). */ enrich?: (span: Span, ctx: HttpContext) => void; /** Request header names to record as `http.request.header.` attributes. */ captureRequestHeaders?: string[]; } /** * OpenTelemetry plugin — one line enables app-wide HTTP server tracing: * * ```ts * import { otel } from "turnover/otel"; * const app = await createApp({ plugins: [otel()] }); * ``` * * With no options it creates a `SERVER` span per request named * `" "` (low-cardinality, using the matched route pattern) with * HTTP semantic-convention attributes, continues an incoming W3C `traceparent`, * and records exceptions and 5xx as errors. The span is the **active** context * for the request, so `@traced` service methods — and any OTel-instrumented * client called from the handler — nest under it automatically. * * Override or extend via options (`ignore`, `enrich`, …) and per-method * `@traced()`. Requires an OpenTelemetry SDK registered by the app; without one * every call is a no-op. * * @param options - Tracing overrides; every field defaults. * @returns A plugin that adds per-request server-span tracing. */ export declare function otel(options?: OtelOptions): Plugin; /** Options for {@link traced} — configure how each span is created. */ export interface TracedOptions { /** * Span name for a method-level `@traced` (default `"."`). A * class-level `@traced` ignores this and always names each span per method. */ name?: string; /** Tracer name (default `"turnover"`). */ tracerName?: string; /** Span kind (default `INTERNAL`). */ kind?: SpanKind; /** Static attributes set on every span this decorator creates. */ attributes?: Attributes; /** Enrich each span before the method runs — e.g. add attributes from args. */ enrich?: (span: Span, joinPoint: JoinPoint) => void; } /** * Trace method calls as child spans, nested under the active server span. * * On a **method**, wrap just that method: * * ```ts * class Orders { * @traced() async place(order: Order) {} // span "Orders.place" * } * ``` * * On a **class**, wrap every public method — convention over configuration — * with per-method opt-out via {@link noTrace}: * * ```ts * @traced() * @injectable() * class Orders { * place(order: Order) {} // traced * @noTrace private hash(order: Order) {} // not traced * } * ``` * * Configure the spans with `kind`, static `attributes`, or an `enrich` callback * (which can read the call's arguments). Needs `createApp` (which auto-registers * the aspect processor) and the class to be resolved through the container. * * @param options - Span configuration (name, kind, attributes, enrich, …). * @returns A class/method decorator that traces the target as child spans. */ export declare function traced(options?: TracedOptions): (value: unknown, decoratorContext: ClassDecoratorContext | ClassMethodDecoratorContext) => void; /** * Method decorator: exclude a method from a class-level `@traced()` — the * "private" opt-out that keeps a method off an otherwise fully-traced class. * * @param _value - The decorated method (unused; metadata is keyed by name). * @param decoratorContext - The standard method-decorator context; its `name` marks the method. */ export declare function noTrace(_value: unknown, decoratorContext: ClassMethodDecoratorContext): void; //# sourceMappingURL=otel.d.ts.map