/** * In-Memory Exporters for Testing * * These exporters capture telemetry data in memory for assertion in tests. * No external connections are made. */ import type { SpanExporter, ReadableSpan } from '@opentelemetry/sdk-trace-base'; import { ExportResult } from '@opentelemetry/core'; /** * In-memory span exporter for testing. * Captures all exported spans for assertion. */ export declare class InMemorySpanExporter implements SpanExporter { private spans; private stopped; /** * Export spans to in-memory storage. */ export(spans: ReadableSpan[], resultCallback: (result: ExportResult) => void): void; /** * Shutdown the exporter. */ shutdown(): Promise; /** * Force flush (no-op for in-memory). */ forceFlush(): Promise; /** * Get all captured spans. */ getSpans(): ReadableSpan[]; /** * Get the number of captured spans. */ getSpanCount(): number; /** * Clear captured spans. */ reset(): void; /** * Find spans by name. * * @param name - Span name to search for * @returns Matching spans */ findSpansByName(name: string): ReadableSpan[]; /** * Find spans by name pattern (regex). * * @param pattern - Regex pattern to match span names * @returns Matching spans */ findSpansByPattern(pattern: RegExp): ReadableSpan[]; /** * Find spans with a specific attribute value. * * @param key - Attribute key * @param value - Attribute value (or regex for pattern matching) * @returns Matching spans */ findSpansByAttribute(key: string, value: string | RegExp): ReadableSpan[]; /** * Assert no spans have a specific attribute value. * Useful for ensuring Tier 1 data doesn't leak. * * @param key - Attribute key * @param value - Forbidden attribute value (or regex pattern) * @throws Error if forbidden attribute is found */ assertNoAttribute(key: string, value: string | RegExp): void; /** * Assert all spans have a required attribute. * * @param key - Attribute key * @throws Error if any span is missing the attribute */ assertAllHaveAttribute(key: string): void; /** * Get span names for debugging. */ getSpanNames(): string[]; } /** * Metric data point captured by in-memory exporter. */ export interface CapturedMetric { name: string; description?: string; unit?: string; type: 'counter' | 'gauge' | 'histogram' | 'observable'; dataPoints: Array<{ value: number; attributes: Record; timestamp: number; }>; } /** * In-memory metric exporter for testing. */ export declare class InMemoryMetricExporter { private metrics; /** * Export metrics to in-memory storage. */ export(metrics: CapturedMetric[]): void; /** * Get all captured metrics. */ getMetrics(): CapturedMetric[]; /** * Find metrics by name. * * @param name - Metric name * @returns Matching metrics */ findMetricsByName(name: string): CapturedMetric[]; /** * Clear captured metrics. */ reset(): void; /** * Assert no metrics have a specific label value. * * @param labelKey - Label key * @param value - Forbidden value * @throws Error if forbidden label is found */ assertNoLabel(labelKey: string, value: string | RegExp): void; } /** * Log record captured by in-memory exporter. */ export interface CapturedLogRecord { timestamp: number; severityNumber: number; severityText?: string; body?: unknown; attributes: Record; } /** * In-memory log exporter for testing. */ export declare class InMemoryLogExporter { private logs; /** * Export logs to in-memory storage. */ export(logs: CapturedLogRecord[]): void; /** * Get all captured logs. */ getLogs(): CapturedLogRecord[]; /** * Find logs by severity. * * @param severityNumber - Severity level (e.g., 9 for INFO, 13 for WARN, 17 for ERROR) * @returns Matching logs */ findLogsBySeverity(severityNumber: number): CapturedLogRecord[]; /** * Find logs containing text. * * @param text - Text to search for in log body * @returns Matching logs */ findLogsContaining(text: string | RegExp): CapturedLogRecord[]; /** * Clear captured logs. */ reset(): void; /** * Assert no logs contain sensitive data. * * @param pattern - Pattern to check for (forbidden content) * @throws Error if forbidden content is found */ assertNoLogContains(pattern: RegExp): void; } //# sourceMappingURL=in-memory-exporter.d.ts.map