import type { MeterProvider } from "@opentelemetry/api"; import type { Outcome } from "./pipeline.js"; /** The envelope fields telemetry needs, so this module does not depend on the full type. */ interface TelemetryEnvelope { readonly id: string; readonly type: string; readonly source: string; readonly subject?: string; readonly traceparent?: string; readonly tracestate?: string; } interface MessageSpanInput { readonly envelope: TelemetryEnvelope; readonly subscription: string; readonly messageId: string; /** The registered pattern that matched, or a bounded sentinel when none did. */ readonly route: string; } export interface TelemetryOptions { /** Default true. When false, every call is a no-op with no OpenTelemetry involvement. */ enabled?: boolean; serviceName: string; /** Injectable for tests; defaults to the globally registered provider. */ meterProvider?: MeterProvider; } type SchemaCacheResult = "hit" | "miss"; export interface Telemetry { withMessageSpan(input: MessageSpanInput, work: () => Promise): Promise; withChildSpan(name: string, work: () => Promise): Promise; /** * Every metric below is labelled by `route` — the registered pattern, or a bounded sentinel for * a message that matched none. Never the raw `ce-type`: that is producer-controlled, and a * wildcard route matches an open-ended set of them, so labelling on it lets one misbehaving * producer mint unbounded metric series. */ recordReceived(route: string, subscription: string): void; recordOutcome(route: string, outcome: Outcome | "skipped_duplicate"): void; recordHandlerDuration(route: string, milliseconds: number): void; recordDecodeFailure(route: string, reason: string): void; recordSchemaCache(result: SchemaCacheResult): void; addInFlight(subscription: string, delta: number): void; recordLateness(route: string, occurredAt: Date, now?: Date): void; } /** * Builds the telemetry facade. * * `@opentelemetry/api` is an optional peer dependency, so it is loaded lazily and everything * degrades to a no-op when it is absent — a consumer that does not want tracing should not have to * install it, and must not crash for skipping it. */ export declare function createTelemetry(options: TelemetryOptions): Telemetry; export {}; //# sourceMappingURL=telemetry.d.ts.map