/**
 * OpenTelemetry Integration
 *
 * Distributed tracing and observability:
 * - Trace context propagation
 * - Span creation and management
 * - Metrics collection (integrated with MetricsCollector)
 * - Log correlation
 * - Multiple export targets (Console, File, OTLP)
 */
import { EventEmitter } from 'events';
export interface OTelConfig {
    /** Service name */
    serviceName: string;
    /** Service version */
    serviceVersion?: string;
    /** Environment */
    environment?: string;
    /** OTLP endpoint */
    endpoint?: string;
    /** Export interval in ms */
    exportInterval?: number;
    /** Enable console exporter */
    consoleExport?: boolean;
    /** Additional resource attributes */
    resourceAttributes?: Record<string, string>;
    /** Sampling rate (0-1) */
    samplingRate?: number;
}
export interface TraceContext {
    traceId: string;
    spanId: string;
    traceFlags: number;
    traceState?: string;
}
export interface SpanContext {
    traceId: string;
    spanId: string;
    parentSpanId?: string;
    name: string;
    kind: SpanKind;
    startTime: number;
    endTime?: number;
    status: SpanStatus;
    attributes: Record<string, AttributeValue>;
    events: SpanEvent[];
    links: SpanLink[];
}
export type SpanKind = 'internal' | 'server' | 'client' | 'producer' | 'consumer';
export interface SpanStatus {
    code: 'unset' | 'ok' | 'error';
    message?: string;
}
export interface SpanEvent {
    name: string;
    timestamp: number;
    attributes?: Record<string, AttributeValue>;
}
export interface SpanLink {
    traceId: string;
    spanId: string;
    attributes?: Record<string, AttributeValue>;
}
export type AttributeValue = string | number | boolean | string[] | number[] | boolean[];
export interface Metric {
    name: string;
    type: 'counter' | 'gauge' | 'histogram';
    description: string;
    unit?: string;
    value: number;
    attributes?: Record<string, string>;
    timestamp: number;
}
export interface Resource {
    attributes: Record<string, string>;
}
/**
 * OpenTelemetry Integration for Code Buddy
 */
export declare class OpenTelemetryIntegration extends EventEmitter {
    private config;
    private resource;
    private activeSpans;
    private spanStack;
    private metrics;
    private exportInterval;
    private initialized;
    private metricsCollector;
    constructor(config: OTelConfig);
    /**
     * Initialize OpenTelemetry
     */
    init(): Promise<void>;
    /**
     * Create resource with service information
     */
    private createResource;
    /**
     * Start a new trace
     */
    startTrace(name: string, options?: {
        kind?: SpanKind;
        attributes?: Record<string, AttributeValue>;
    }): string;
    /**
     * Start a child span
     */
    startSpan(name: string, options?: {
        kind?: SpanKind;
        attributes?: Record<string, AttributeValue>;
    }): string;
    /**
     * End a span
     */
    endSpan(spanId: string, status?: SpanStatus): void;
    /**
     * Add event to current span
     */
    addEvent(name: string, attributes?: Record<string, AttributeValue>): void;
    /**
     * Set attribute on current span
     */
    setAttribute(key: string, value: AttributeValue): void;
    /**
     * Set error on current span
     */
    recordException(error: Error): void;
    /**
     * Get current trace context
     */
    getTraceContext(): TraceContext | null;
    /**
     * Create a context from W3C traceparent header
     */
    extractContext(traceparent: string): TraceContext | null;
    /**
     * Create W3C traceparent header from context
     */
    injectContext(context: TraceContext): string;
    /**
     * Record a counter metric
     * Uses MetricsCollector if available, falls back to internal storage
     */
    recordCounter(name: string, value?: number, attributes?: Record<string, string>): void;
    /**
     * Record a gauge metric
     * Uses MetricsCollector if available, falls back to internal storage
     */
    recordGauge(name: string, value: number, attributes?: Record<string, string>): void;
    /**
     * Record a histogram metric
     * Uses MetricsCollector if available, falls back to internal storage
     */
    recordHistogram(name: string, value: number, attributes?: Record<string, string>): void;
    /**
     * Measure function execution time
     */
    measure<T>(name: string, fn: () => Promise<T>): Promise<T>;
    /**
     * Export span to OTLP endpoint
     */
    private exportSpan;
    /**
     * Format span for OTLP
     */
    private formatSpan;
    /**
     * Get span kind number
     */
    private getSpanKindNumber;
    /**
     * Format attribute value for OTLP
     */
    private formatAttributeValue;
    /**
     * Export metrics to OTLP endpoint
     */
    private exportMetrics;
    /**
     * Format metric group for OTLP
     */
    private formatMetricGroup;
    /**
     * Generate trace ID (32 hex chars)
     */
    private generateTraceId;
    /**
     * Generate span ID (16 hex chars)
     */
    private generateSpanId;
    /**
     * Shutdown OpenTelemetry
     */
    shutdown(): Promise<void>;
}
/**
 * Initialize OpenTelemetry
 */
export declare function initOpenTelemetry(config: OTelConfig): OpenTelemetryIntegration;
/**
 * Get OpenTelemetry instance
 */
export declare function getOpenTelemetry(): OpenTelemetryIntegration | null;
/**
 * Trace a function
 */
export declare function trace<T>(name: string, fn: () => Promise<T>): Promise<T>;
export default OpenTelemetryIntegration;
