/** * Test helpers — in-memory OTEL collectors, config factory, mock logger. * * Uses the OTEL SDK's built-in InMemoryMetricExporter and * InMemoryLogRecordExporter to capture telemetry emitted by the plugin, * then provides query helpers to inspect the collected data. */ import { InMemoryMetricExporter } from "@opentelemetry/sdk-metrics"; import { InMemoryLogRecordExporter } from "@opentelemetry/sdk-logs"; import type { ReadableLogRecord } from "@opentelemetry/sdk-logs"; import type { Attributes } from "@opentelemetry/api"; import { type TelemetryContext } from "../telemetry.js"; import { type HookState } from "../hooks.js"; import type { OtelConfig } from "../config.js"; import type { Logger } from "../log.js"; /** Create a test config with optional overrides. */ export declare function testConfig(overrides?: Partial): OtelConfig; export declare function noopLogger(): Logger; export interface TestHarness { config: OtelConfig; telemetry: TelemetryContext; state: HookState; metricExporter: InMemoryMetricExporter; logExporter: InMemoryLogRecordExporter; /** Dispatch an event through the hook system. */ emit: (event: { type: string; properties?: any; }) => void; /** * Force-flush metrics so they appear in the in-memory exporter. * Must be called before querying metrics (counters are async). */ flush: () => Promise; /** Tear down the OTEL providers. */ shutdown: () => Promise; /** Get all collected log events. */ getEvents: () => ReadableLogRecord[]; /** Get log events matching a given event name. */ getEventsByName: (name: string) => ReadableLogRecord[]; /** * Get all metric data points, flattened into a simple list. * Each entry has { name, value, attributes }. */ getMetricDataPoints: () => MetricDataPoint[]; /** * Get metric data points matching a given metric name. */ getMetricsByName: (name: string) => MetricDataPoint[]; /** Get resource attributes from the metric exporter. */ getResourceAttributes: () => Attributes; /** Reset both exporters (clear collected data). */ reset: () => void; } export interface MetricDataPoint { name: string; description: string; unit: string; value: number; attributes: Attributes; } /** * Create a fully wired test harness with in-memory exporters. * Each call creates an isolated telemetry context. */ export declare function createTestHarness(configOverrides?: Partial): TestHarness;