@datalayer/core 1.0.2 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/README.md +1 -1
  2. package/lib/api/constants.d.ts +6 -0
  3. package/lib/api/constants.js +6 -0
  4. package/lib/api/index.d.ts +1 -0
  5. package/lib/api/index.js +1 -0
  6. package/lib/api/otel/index.d.ts +12 -0
  7. package/lib/api/otel/index.js +16 -0
  8. package/lib/api/otel/logs.d.ts +19 -0
  9. package/lib/api/otel/logs.js +43 -0
  10. package/lib/api/otel/metrics.d.ts +31 -0
  11. package/lib/api/otel/metrics.js +65 -0
  12. package/lib/api/otel/query.d.ts +16 -0
  13. package/lib/api/otel/query.js +37 -0
  14. package/lib/api/otel/services.d.ts +39 -0
  15. package/lib/api/otel/services.js +81 -0
  16. package/lib/api/otel/traces.d.ts +24 -0
  17. package/lib/api/otel/traces.js +53 -0
  18. package/lib/api/otel/types.d.ts +112 -0
  19. package/lib/api/otel/types.js +5 -0
  20. package/lib/api/runtimes/checkpoints.d.ts +122 -0
  21. package/lib/api/runtimes/checkpoints.js +118 -0
  22. package/lib/api/runtimes/index.d.ts +1 -0
  23. package/lib/api/runtimes/index.js +1 -0
  24. package/lib/api/runtimes/runtimes.d.ts +84 -0
  25. package/lib/api/runtimes/runtimes.js +50 -0
  26. package/lib/components/auth/Login.js +1 -1
  27. package/lib/components/display/BusyDots.d.ts +9 -0
  28. package/lib/components/display/BusyDots.js +31 -0
  29. package/lib/components/display/LiveRelativeTime.d.ts +10 -0
  30. package/lib/components/display/LiveRelativeTime.js +21 -0
  31. package/lib/components/display/index.d.ts +2 -0
  32. package/lib/components/display/index.js +2 -0
  33. package/lib/components/flashes/FlashSurveys.js +1 -1
  34. package/lib/components/index.d.ts +1 -0
  35. package/lib/components/index.js +1 -0
  36. package/lib/components/navbar/SubdomainNavBar.js +1 -1
  37. package/lib/components/progress/ConsumptionBar.js +6 -7
  38. package/lib/components/progress/CreditsIndicator.js +2 -2
  39. package/lib/components/progress/consumption.d.ts +12 -0
  40. package/lib/components/progress/consumption.js +31 -0
  41. package/lib/components/progress/index.d.ts +1 -0
  42. package/lib/components/progress/index.js +1 -0
  43. package/lib/components/sparklines/Sparklines.d.ts +16 -0
  44. package/lib/components/sparklines/Sparklines.js +65 -0
  45. package/lib/components/sparklines/SparklinesLine.d.ts +8 -0
  46. package/lib/components/sparklines/SparklinesLine.js +37 -0
  47. package/lib/components/sparklines/dataProcessing.d.ts +25 -0
  48. package/lib/components/sparklines/dataProcessing.js +35 -0
  49. package/lib/components/sparklines/index.d.ts +4 -0
  50. package/lib/components/sparklines/index.js +7 -0
  51. package/lib/components/sparklines/types.d.ts +36 -0
  52. package/lib/components/sparklines/types.js +5 -0
  53. package/lib/components/storage/ContentsBrowser.js +17 -1
  54. package/lib/components/subnav/SubNav.js +1 -1
  55. package/lib/config/Configuration.d.ts +4 -0
  56. package/lib/hooks/useCache.d.ts +6 -63
  57. package/lib/hooks/useCache.js +35 -205
  58. package/lib/hooks/useProjects.d.ts +1 -1
  59. package/lib/index.d.ts +2 -0
  60. package/lib/index.js +4 -0
  61. package/lib/models/ItemDTO.js +1 -1
  62. package/lib/models/RolesPlatform.js +2 -2
  63. package/lib/models/User.d.ts +2 -0
  64. package/lib/models/User.js +4 -1
  65. package/lib/otel/client/OtelClient.d.ts +93 -0
  66. package/lib/otel/client/OtelClient.js +232 -0
  67. package/lib/otel/client/index.d.ts +2 -0
  68. package/lib/otel/client/index.js +5 -0
  69. package/lib/otel/hooks/index.d.ts +186 -0
  70. package/lib/otel/hooks/index.js +532 -0
  71. package/lib/otel/index.d.ts +34 -0
  72. package/lib/otel/index.js +23 -0
  73. package/lib/otel/types.d.ts +190 -0
  74. package/lib/otel/types.js +5 -0
  75. package/lib/otel/utils.d.ts +33 -0
  76. package/lib/otel/utils.js +181 -0
  77. package/lib/otel/views/OtelLive.d.ts +12 -0
  78. package/lib/otel/views/OtelLive.js +372 -0
  79. package/lib/otel/views/OtelLogsList.d.ts +11 -0
  80. package/lib/otel/views/OtelLogsList.js +137 -0
  81. package/lib/otel/views/OtelMetricsChart.d.ts +22 -0
  82. package/lib/otel/views/OtelMetricsChart.js +300 -0
  83. package/lib/otel/views/OtelMetricsList.d.ts +15 -0
  84. package/lib/otel/views/OtelMetricsList.js +213 -0
  85. package/lib/otel/views/OtelSearchBar.d.ts +11 -0
  86. package/lib/otel/views/OtelSearchBar.js +22 -0
  87. package/lib/otel/views/OtelSpanDetail.d.ts +11 -0
  88. package/lib/otel/views/OtelSpanDetail.js +172 -0
  89. package/lib/otel/views/OtelSpanTree.d.ts +11 -0
  90. package/lib/otel/views/OtelSpanTree.js +176 -0
  91. package/lib/otel/views/OtelSqlView.d.ts +16 -0
  92. package/lib/otel/views/OtelSqlView.js +239 -0
  93. package/lib/otel/views/OtelSystemView.d.ts +15 -0
  94. package/lib/otel/views/OtelSystemView.js +75 -0
  95. package/lib/otel/views/OtelTimeline.d.ts +11 -0
  96. package/lib/otel/views/OtelTimeline.js +101 -0
  97. package/lib/otel/views/OtelTimelineRangeSlider.d.ts +16 -0
  98. package/lib/otel/views/OtelTimelineRangeSlider.js +338 -0
  99. package/lib/otel/views/OtelTracesList.d.ts +13 -0
  100. package/lib/otel/views/OtelTracesList.js +199 -0
  101. package/lib/otel/views/index.d.ts +20 -0
  102. package/lib/otel/views/index.js +21 -0
  103. package/lib/state/storage/IAMStorage.d.ts +2 -1
  104. package/lib/state/substates/CoreState.js +7 -6
  105. package/lib/utils/Date.d.ts +6 -0
  106. package/lib/utils/Date.js +37 -0
  107. package/lib/utils/Jwt.d.ts +42 -0
  108. package/lib/utils/Jwt.js +44 -0
  109. package/lib/utils/index.d.ts +1 -0
  110. package/lib/utils/index.js +1 -0
  111. package/lib/views/iam/SignInSimple.d.ts +43 -0
  112. package/lib/views/iam/SignInSimple.js +113 -0
  113. package/lib/views/iam/index.d.ts +2 -0
  114. package/lib/views/iam/index.js +5 -0
  115. package/lib/views/iam-tokens/IAMTokenEdit.d.ts +5 -1
  116. package/lib/views/iam-tokens/IAMTokenEdit.js +54 -5
  117. package/lib/views/iam-tokens/IAMTokenNew.js +2 -2
  118. package/lib/views/iam-tokens/IAMTokens.d.ts +4 -2
  119. package/lib/views/iam-tokens/IAMTokens.js +68 -36
  120. package/lib/views/iam-tokens/Tokens.js +63 -31
  121. package/lib/views/index.d.ts +3 -1
  122. package/lib/views/index.js +3 -1
  123. package/lib/views/otel/DashboardView.d.ts +16 -0
  124. package/lib/views/otel/DashboardView.js +4 -0
  125. package/lib/views/otel/LogsView.d.ts +12 -0
  126. package/lib/views/otel/LogsView.js +4 -0
  127. package/lib/views/otel/MetricsView.d.ts +12 -0
  128. package/lib/views/otel/MetricsView.js +4 -0
  129. package/lib/views/otel/OtelHeader.d.ts +33 -0
  130. package/lib/views/otel/OtelHeader.js +105 -0
  131. package/lib/views/otel/SqlView.d.ts +9 -0
  132. package/lib/views/otel/SqlView.js +4 -0
  133. package/lib/views/otel/SystemView.d.ts +9 -0
  134. package/lib/views/otel/SystemView.js +4 -0
  135. package/lib/views/otel/TracesView.d.ts +12 -0
  136. package/lib/views/otel/TracesView.js +4 -0
  137. package/lib/views/otel/index.d.ts +16 -0
  138. package/lib/views/otel/index.js +12 -0
  139. package/lib/views/otel/simpleAuthStore.d.ts +21 -0
  140. package/lib/views/otel/simpleAuthStore.js +22 -0
  141. package/lib/views/profile/UserBadge.d.ts +20 -0
  142. package/lib/views/profile/UserBadge.js +101 -0
  143. package/lib/views/profile/index.d.ts +2 -0
  144. package/lib/views/profile/index.js +5 -0
  145. package/package.json +3 -4
@@ -0,0 +1,232 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * OtelClient – Typed HTTP client for the Datalayer OTEL service.
7
+ *
8
+ * Reads the OTEL service URL from the Datalayer core configuration by default,
9
+ * so callers don't need to pass `baseUrl` unless they want to override it.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * import { createOtelClient } from '@datalayer/core/otel';
14
+ *
15
+ * const client = createOtelClient({ token: myJwt });
16
+ * const { data: spans } = await client.fetchTraces({ limit: 50 });
17
+ * ```
18
+ */
19
+ import { coreStore } from '../../state/substates/CoreState';
20
+ // ── Fetch helper ────────────────────────────────────────────────────────────
21
+ async function otelFetch(url, token, options) {
22
+ const headers = {
23
+ Accept: 'application/json',
24
+ 'Cache-Control': 'no-store, no-cache, must-revalidate',
25
+ };
26
+ if (token) {
27
+ headers['Authorization'] = `Bearer ${token}`;
28
+ }
29
+ if (options?.body) {
30
+ headers['Content-Type'] = 'application/json';
31
+ }
32
+ const resp = await fetch(url, {
33
+ method: options?.method ?? 'GET',
34
+ headers,
35
+ body: options?.body != null ? JSON.stringify(options.body) : undefined,
36
+ });
37
+ if (!resp.ok) {
38
+ const text = await resp.text().catch(() => '');
39
+ throw new Error(`OTEL API error ${resp.status}: ${text}`);
40
+ }
41
+ return resp.json();
42
+ }
43
+ function parseMetricValue(raw) {
44
+ const candidates = [raw.value, raw.value_double, raw.value_int];
45
+ for (const candidate of candidates) {
46
+ if (typeof candidate === 'number' && Number.isFinite(candidate)) {
47
+ return candidate;
48
+ }
49
+ if (typeof candidate === 'string') {
50
+ const parsed = Number(candidate);
51
+ if (Number.isFinite(parsed)) {
52
+ return parsed;
53
+ }
54
+ }
55
+ }
56
+ return 0;
57
+ }
58
+ function parseMetricTimestamp(raw) {
59
+ const candidate = raw.timestamp ??
60
+ raw.Timestamp ??
61
+ raw.timestamp_unix_nano ??
62
+ raw.start_time_unix_nano;
63
+ if (typeof candidate === 'string' && candidate.trim().length > 0) {
64
+ return candidate;
65
+ }
66
+ const numeric = Number(candidate);
67
+ if (!Number.isFinite(numeric)) {
68
+ return '';
69
+ }
70
+ if (numeric > 1e15) {
71
+ return new Date(numeric / 1e6).toISOString();
72
+ }
73
+ if (numeric > 1e12) {
74
+ return new Date(numeric / 1e3).toISOString();
75
+ }
76
+ return new Date(numeric).toISOString();
77
+ }
78
+ function normalizeMetric(raw) {
79
+ return {
80
+ metric_name: String(raw.metric_name ?? raw.MetricName ?? raw.name ?? raw.Name ?? ''),
81
+ service_name: String(raw.service_name ?? raw.ServiceName ?? ''),
82
+ value: parseMetricValue(raw),
83
+ unit: raw.metric_unit != null
84
+ ? String(raw.metric_unit)
85
+ : raw.MetricUnit != null
86
+ ? String(raw.MetricUnit)
87
+ : raw.unit != null
88
+ ? String(raw.unit)
89
+ : raw.Unit != null
90
+ ? String(raw.Unit)
91
+ : undefined,
92
+ timestamp: parseMetricTimestamp(raw),
93
+ metric_type: raw.metric_type != null
94
+ ? String(raw.metric_type)
95
+ : raw.MetricType != null
96
+ ? String(raw.MetricType)
97
+ : undefined,
98
+ attributes: typeof raw.attributes === 'object' && raw.attributes !== null
99
+ ? raw.attributes
100
+ : undefined,
101
+ };
102
+ }
103
+ // ── OtelClient class ─────────────────────────────────────────────────────────
104
+ /**
105
+ * Typed HTTP client for all OTEL service endpoints.
106
+ *
107
+ * Construct via `createOtelClient()` or `new OtelClient(options)`.
108
+ */
109
+ export class OtelClient {
110
+ baseUrl;
111
+ token;
112
+ constructor(options = {}) {
113
+ this.baseUrl =
114
+ options.baseUrl ?? coreStore.getState().configuration.otelRunUrl;
115
+ this.token = options.token;
116
+ }
117
+ // ── Traces ────────────────────────────────────────────────────────────────
118
+ /** List recent spans / traces. */
119
+ async fetchTraces(options = {}) {
120
+ const params = new URLSearchParams({ limit: String(options.limit ?? 50) });
121
+ if (options.serviceName)
122
+ params.set('service_name', options.serviceName);
123
+ const resp = await otelFetch(`${this.baseUrl}/api/otel/v1/traces/?${params}`, this.token);
124
+ const rows = (Array.isArray(resp) ? resp : resp.data) ?? [];
125
+ return { data: rows, count: rows.length };
126
+ }
127
+ /** Fetch all spans for a single trace by `traceId`. */
128
+ async fetchTrace(traceId) {
129
+ const resp = await otelFetch(`${this.baseUrl}/api/otel/v1/traces/${traceId}`, this.token);
130
+ const rows = (Array.isArray(resp) ? resp : resp.data) ?? [];
131
+ return { data: rows };
132
+ }
133
+ // ── Logs ──────────────────────────────────────────────────────────────────
134
+ /** List recent log records. */
135
+ async fetchLogs(options = {}) {
136
+ const params = new URLSearchParams({ limit: String(options.limit ?? 100) });
137
+ if (options.serviceName)
138
+ params.set('service_name', options.serviceName);
139
+ if (options.severity)
140
+ params.set('severity', options.severity);
141
+ if (options.traceId)
142
+ params.set('trace_id', options.traceId);
143
+ const resp = await otelFetch(`${this.baseUrl}/api/otel/v1/logs/?${params}`, this.token);
144
+ const rows = (Array.isArray(resp) ? resp : resp.data) ?? [];
145
+ return { data: rows, count: rows.length };
146
+ }
147
+ // ── Metrics ───────────────────────────────────────────────────────────────
148
+ /** List recent metric data points. */
149
+ async fetchMetrics(options = {}) {
150
+ const params = new URLSearchParams({ limit: String(options.limit ?? 50) });
151
+ if (options.serviceName)
152
+ params.set('service_name', options.serviceName);
153
+ if (options.metricName)
154
+ params.set('metric_name', options.metricName);
155
+ const resp = await otelFetch(`${this.baseUrl}/api/otel/v1/metrics/?${params}`, this.token);
156
+ const rows = (Array.isArray(resp) ? resp : resp.data) ?? [];
157
+ const normalized = Array.isArray(rows)
158
+ ? rows.map(row => normalizeMetric(row))
159
+ : [];
160
+ return { data: normalized, count: normalized.length };
161
+ }
162
+ /** Sum all values for one metric name, with optional service filter. */
163
+ async fetchMetricTotal(metricName, options = {}) {
164
+ const { serviceName, limit = 500, fallbackWithoutService = true } = options;
165
+ const filtered = await this.fetchMetrics({
166
+ metricName,
167
+ serviceName,
168
+ limit,
169
+ });
170
+ const filteredTotal = filtered.data.reduce((sum, row) => sum + Number(row.value || 0), 0);
171
+ if (filteredTotal > 0 || !serviceName || !fallbackWithoutService) {
172
+ return filteredTotal;
173
+ }
174
+ const unfiltered = await this.fetchMetrics({ metricName, limit });
175
+ return unfiltered.data.reduce((sum, row) => sum + Number(row.value || 0), 0);
176
+ }
177
+ // ── Services ──────────────────────────────────────────────────────────────
178
+ /** List known service names observed in traces. */
179
+ async fetchServices() {
180
+ const resp = await otelFetch(`${this.baseUrl}/api/otel/v1/traces/services/list`, this.token);
181
+ if (Array.isArray(resp))
182
+ return resp;
183
+ const byServices = resp.services;
184
+ if (Array.isArray(byServices))
185
+ return byServices;
186
+ const byData = resp.data;
187
+ if (Array.isArray(byData)) {
188
+ return byData.map((r) => String(r.service_name ?? r.name ?? ''));
189
+ }
190
+ return [];
191
+ }
192
+ // ── Stats ─────────────────────────────────────────────────────────────────
193
+ /** Fetch storage / ingestion statistics. */
194
+ async fetchStats() {
195
+ return otelFetch(`${this.baseUrl}/api/otel/v1/stats/`, this.token);
196
+ }
197
+ // ── SQL query ─────────────────────────────────────────────────────────────
198
+ /**
199
+ * Execute an ad-hoc DataFusion SQL query against the OTEL service.
200
+ *
201
+ * Available tables: `spans`, `logs`, `metrics`.
202
+ */
203
+ async executeQuery(sql) {
204
+ return otelFetch(`${this.baseUrl}/api/otel/v1/query/`, this.token, { method: 'POST', body: { sql } });
205
+ }
206
+ // ── System ────────────────────────────────────────────────────────────────
207
+ /**
208
+ * Fetch system statistics (platform_admin only).
209
+ *
210
+ * Returns process memory/CPU, disk usage, and per-table row counts.
211
+ */
212
+ async fetchSystem() {
213
+ const resp = await otelFetch(`${this.baseUrl}/api/otel/v1/system/`, this.token);
214
+ return (resp.data ?? resp);
215
+ }
216
+ }
217
+ // ── Factory ──────────────────────────────────────────────────────────────────
218
+ /**
219
+ * Create a new `OtelClient`.
220
+ *
221
+ * The `baseUrl` defaults to `configuration.otelRunUrl` from the Datalayer core
222
+ * configuration store, so only pass it when you want to override the default.
223
+ *
224
+ * @example
225
+ * ```ts
226
+ * const client = createOtelClient({ token: jwt });
227
+ * const services = await client.fetchServices();
228
+ * ```
229
+ */
230
+ export function createOtelClient(options = {}) {
231
+ return new OtelClient(options);
232
+ }
@@ -0,0 +1,2 @@
1
+ export { OtelClient, createOtelClient } from './OtelClient';
2
+ export type { OtelClientOptions, FetchTracesOptions, FetchLogsOptions, FetchMetricsOptions, FetchMetricTotalOptions, OtelSystemData, OtelSystemProcess, OtelSystemDisk, OtelSystemTable, } from './OtelClient';
@@ -0,0 +1,5 @@
1
+ /*
2
+ * Copyright (c) 2023-2025 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ export { OtelClient, createOtelClient } from './OtelClient';
@@ -0,0 +1,186 @@
1
+ import type { OtelSpan, OtelLog, OtelMetric, OtelQueryRow } from '../types';
2
+ /**
3
+ * Register a callback invoked whenever an OTEL API call receives a
4
+ * **401 Unauthorized** response. Typically used to clear auth state
5
+ * (i.e. log the user out) when the token has expired.
6
+ *
7
+ * Pass `null` to unregister.
8
+ *
9
+ * @example
10
+ * ```ts
11
+ * import { setOtelOnUnauthorized } from '@datalayer/core/lib/otel';
12
+ * setOtelOnUnauthorized(() => authStore.getState().clearAuth());
13
+ * ```
14
+ */
15
+ export declare function setOtelOnUnauthorized(cb: (() => void) | null): void;
16
+ /** Fetch a list of traces / spans from the OTEL service. */
17
+ export declare function useOtelTraces(options: {
18
+ token?: string;
19
+ baseUrl?: string;
20
+ serviceName?: string;
21
+ limit?: number;
22
+ autoRefreshMs?: number;
23
+ }): {
24
+ traces: OtelSpan[];
25
+ loading: boolean;
26
+ error: string | null;
27
+ refetch: () => Promise<void>;
28
+ };
29
+ /** Fetch all spans for a single trace. */
30
+ export declare function useOtelTrace(options: {
31
+ traceId: string | null;
32
+ token?: string;
33
+ baseUrl?: string;
34
+ }): {
35
+ spans: OtelSpan[];
36
+ loading: boolean;
37
+ error: string | null;
38
+ };
39
+ /** Fetch log records from the OTEL service. */
40
+ export declare function useOtelLogs(options: {
41
+ token?: string;
42
+ baseUrl?: string;
43
+ serviceName?: string;
44
+ severity?: string;
45
+ traceId?: string;
46
+ limit?: number;
47
+ autoRefreshMs?: number;
48
+ }): {
49
+ logs: OtelLog[];
50
+ loading: boolean;
51
+ error: string | null;
52
+ refetch: () => Promise<void>;
53
+ };
54
+ /** Fetch metrics from the OTEL service. */
55
+ export declare function useOtelMetrics(options: {
56
+ token?: string;
57
+ baseUrl?: string;
58
+ serviceName?: string;
59
+ metricName?: string;
60
+ limit?: number;
61
+ autoRefreshMs?: number;
62
+ }): {
63
+ metrics: OtelMetric[];
64
+ loading: boolean;
65
+ error: string | null;
66
+ refetch: () => Promise<void>;
67
+ };
68
+ /** Fetch list of observed service names. */
69
+ export declare function useOtelServices(options: {
70
+ token?: string;
71
+ baseUrl?: string;
72
+ }): {
73
+ services: string[];
74
+ loading: boolean;
75
+ };
76
+ /** Fetch storage stats from the OTEL service. */
77
+ export declare function useOtelStats(options: {
78
+ token?: string;
79
+ baseUrl?: string;
80
+ }): {
81
+ stats: Record<string, unknown>;
82
+ loading: boolean;
83
+ };
84
+ export interface OtelSystemProcess {
85
+ memory_rss_bytes: number;
86
+ memory_vms_bytes: number;
87
+ cpu_percent: number;
88
+ num_threads: number;
89
+ error?: string;
90
+ }
91
+ export interface OtelSystemDisk {
92
+ data_dir: string;
93
+ used_bytes: number;
94
+ free_bytes: number;
95
+ total_bytes: number;
96
+ used_percent: number;
97
+ error?: string;
98
+ }
99
+ export interface OtelSystemTable {
100
+ row_count: number;
101
+ distinct_users: number;
102
+ disk_bytes: number;
103
+ error?: string;
104
+ }
105
+ export interface OtelSystemData {
106
+ process: OtelSystemProcess;
107
+ disk: OtelSystemDisk;
108
+ tables: Record<string, OtelSystemTable>;
109
+ total_distinct_users: number;
110
+ }
111
+ /** Fetch system statistics from /api/otel/v1/system/ (platform_admin). */
112
+ export declare function useOtelSystem(options: {
113
+ token?: string;
114
+ baseUrl?: string;
115
+ }): {
116
+ data: OtelSystemData | null;
117
+ loading: boolean;
118
+ error: string | null;
119
+ refresh: () => void;
120
+ };
121
+ /**
122
+ * Execute an ad-hoc DataFusion SQL query against the OTEL service.
123
+ *
124
+ * Usage:
125
+ * ```tsx
126
+ * const { execute, rows, loading, error } = useOtelQuery({ baseUrl, token });
127
+ * await execute('SELECT trace_id FROM spans LIMIT 10');
128
+ * ```
129
+ */
130
+ export declare function useOtelQuery(options: {
131
+ token?: string;
132
+ baseUrl?: string;
133
+ }): {
134
+ rows: OtelQueryRow[];
135
+ loading: boolean;
136
+ error: string | null;
137
+ execute: (sql: string) => Promise<void>;
138
+ clear: () => void;
139
+ };
140
+ /** WebSocket message shape sent by the OTEL service. */
141
+ export interface OtelWsMessage {
142
+ signal: 'traces' | 'logs' | 'metrics';
143
+ data: Record<string, unknown>[];
144
+ count: number;
145
+ }
146
+ /** Callbacks for WebSocket lifecycle events. */
147
+ export interface OtelWsCallbacks {
148
+ /** Called when new traces are flushed. */
149
+ onTraces?: (spans: OtelSpan[]) => void;
150
+ /** Called when new logs are flushed. */
151
+ onLogs?: (logs: OtelLog[]) => void;
152
+ /** Called when new metrics are flushed. */
153
+ onMetrics?: (metrics: OtelMetric[]) => void;
154
+ /** Called on any message (raw). */
155
+ onMessage?: (msg: OtelWsMessage) => void;
156
+ /** Called when connection opens. */
157
+ onOpen?: () => void;
158
+ /** Called when connection closes. */
159
+ onClose?: (event: CloseEvent) => void;
160
+ /** Called on error. */
161
+ onError?: (event: Event) => void;
162
+ }
163
+ /**
164
+ * Connect to the OTEL service WebSocket for live telemetry streaming.
165
+ *
166
+ * The server pushes JSON messages whenever new data is flushed to storage.
167
+ * Authentication is via the `token` query parameter (JWT or API key).
168
+ *
169
+ * @returns `{ connected, error, close }` – reactive connection state.
170
+ */
171
+ export declare function useOtelWebSocket(options: {
172
+ /** OTEL service base URL (e.g. `http://localhost:7800`). */
173
+ baseUrl?: string;
174
+ /** JWT token or API key for authentication. */
175
+ token?: string;
176
+ /** Whether to automatically reconnect on disconnect. Default true. */
177
+ autoReconnect?: boolean;
178
+ /** Reconnect delay in ms. Default 3000. */
179
+ reconnectDelayMs?: number;
180
+ /** Callbacks for signal events. */
181
+ callbacks?: OtelWsCallbacks;
182
+ }): {
183
+ connected: boolean;
184
+ error: string | null;
185
+ close: () => void;
186
+ };