import type { OtelSpan, OtelLog, OtelMetric, OtelQueryRow } from '../types';
/**
 * Register a callback invoked whenever an OTEL API call receives a
 * **401 Unauthorized** response.  Typically used to clear auth state
 * (i.e. log the user out) when the token has expired.
 *
 * Pass `null` to unregister.
 *
 * @example
 * ```ts
 * import { setOtelOnUnauthorized } from '@datalayer/core/lib/otel';
 * setOtelOnUnauthorized(() => authStore.getState().clearAuth());
 * ```
 */
export declare function setOtelOnUnauthorized(cb: (() => void) | null): void;
/** Fetch a list of traces / spans from the OTEL service. */
export declare function useOtelTraces(options: {
    token?: string;
    baseUrl?: string;
    serviceName?: string;
    limit?: number;
    autoRefreshMs?: number;
}): {
    traces: OtelSpan[];
    loading: boolean;
    error: string | null;
    refetch: () => Promise<void>;
};
/** Fetch all spans for a single trace. */
export declare function useOtelTrace(options: {
    traceId: string | null;
    token?: string;
    baseUrl?: string;
}): {
    spans: OtelSpan[];
    loading: boolean;
    error: string | null;
};
/** Fetch log records from the OTEL service. */
export declare function useOtelLogs(options: {
    token?: string;
    baseUrl?: string;
    serviceName?: string;
    severity?: string;
    traceId?: string;
    limit?: number;
    autoRefreshMs?: number;
}): {
    logs: OtelLog[];
    loading: boolean;
    error: string | null;
    refetch: () => Promise<void>;
};
/** Fetch metrics from the OTEL service. */
export declare function useOtelMetrics(options: {
    token?: string;
    baseUrl?: string;
    serviceName?: string;
    metricName?: string;
    limit?: number;
    autoRefreshMs?: number;
}): {
    metrics: OtelMetric[];
    loading: boolean;
    error: string | null;
    refetch: () => Promise<void>;
};
/** Fetch list of observed service names. */
export declare function useOtelServices(options: {
    token?: string;
    baseUrl?: string;
}): {
    services: string[];
    loading: boolean;
};
/** Fetch storage stats from the OTEL service. */
export declare function useOtelStats(options: {
    token?: string;
    baseUrl?: string;
}): {
    stats: Record<string, unknown>;
    loading: boolean;
};
export interface OtelSystemProcess {
    memory_rss_bytes: number;
    memory_vms_bytes: number;
    cpu_percent: number;
    num_threads: number;
    error?: string;
}
export interface OtelSystemDisk {
    data_dir: string;
    used_bytes: number;
    free_bytes: number;
    total_bytes: number;
    used_percent: number;
    error?: string;
}
export interface OtelSystemTable {
    row_count: number;
    distinct_users: number;
    disk_bytes: number;
    error?: string;
}
export interface OtelSystemData {
    process: OtelSystemProcess;
    disk: OtelSystemDisk;
    tables: Record<string, OtelSystemTable>;
    total_distinct_users: number;
}
/** Fetch system statistics from /api/otel/v1/system/ (platform_admin). */
export declare function useOtelSystem(options: {
    token?: string;
    baseUrl?: string;
}): {
    data: OtelSystemData | null;
    loading: boolean;
    error: string | null;
    refresh: () => void;
};
/**
 * Execute an ad-hoc DataFusion SQL query against the OTEL service.
 *
 * Usage:
 * ```tsx
 * const { execute, rows, loading, error } = useOtelQuery({ baseUrl, token });
 * await execute('SELECT trace_id FROM spans LIMIT 10');
 * ```
 */
export declare function useOtelQuery(options: {
    token?: string;
    baseUrl?: string;
}): {
    rows: OtelQueryRow[];
    loading: boolean;
    error: string | null;
    execute: (sql: string) => Promise<void>;
    clear: () => void;
};
/** WebSocket message shape sent by the OTEL service. */
export interface OtelWsMessage {
    signal: 'traces' | 'logs' | 'metrics';
    data: Record<string, unknown>[];
    count: number;
}
/** Callbacks for WebSocket lifecycle events. */
export interface OtelWsCallbacks {
    /** Called when new traces are flushed. */
    onTraces?: (spans: OtelSpan[]) => void;
    /** Called when new logs are flushed. */
    onLogs?: (logs: OtelLog[]) => void;
    /** Called when new metrics are flushed. */
    onMetrics?: (metrics: OtelMetric[]) => void;
    /** Called on any message (raw). */
    onMessage?: (msg: OtelWsMessage) => void;
    /** Called when connection opens. */
    onOpen?: () => void;
    /** Called when connection closes. */
    onClose?: (event: CloseEvent) => void;
    /** Called on error. */
    onError?: (event: Event) => void;
}
/**
 * Connect to the OTEL service WebSocket for live telemetry streaming.
 *
 * The server pushes JSON messages whenever new data is flushed to storage.
 * Authentication is via the `token` query parameter (JWT or API key).
 *
 * @returns `{ connected, error, close }` – reactive connection state.
 */
export declare function useOtelWebSocket(options: {
    /** OTEL service base URL (e.g. `http://localhost:7800`). */
    baseUrl?: string;
    /** JWT token or API key for authentication. */
    token?: string;
    /** Explicit user UID; optional when token contains user.uid/sub. */
    userUid?: string;
    /** Whether to automatically reconnect on disconnect. Default true. */
    autoReconnect?: boolean;
    /** Reconnect delay in ms. Default 3000. */
    reconnectDelayMs?: number;
    /** Callbacks for signal events. */
    callbacks?: OtelWsCallbacks;
}): {
    connected: boolean;
    error: string | null;
    close: () => void;
};
