@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.
- package/README.md +1 -1
- package/lib/api/constants.d.ts +6 -0
- package/lib/api/constants.js +6 -0
- package/lib/api/index.d.ts +1 -0
- package/lib/api/index.js +1 -0
- package/lib/api/otel/index.d.ts +12 -0
- package/lib/api/otel/index.js +16 -0
- package/lib/api/otel/logs.d.ts +19 -0
- package/lib/api/otel/logs.js +43 -0
- package/lib/api/otel/metrics.d.ts +31 -0
- package/lib/api/otel/metrics.js +65 -0
- package/lib/api/otel/query.d.ts +16 -0
- package/lib/api/otel/query.js +37 -0
- package/lib/api/otel/services.d.ts +39 -0
- package/lib/api/otel/services.js +81 -0
- package/lib/api/otel/traces.d.ts +24 -0
- package/lib/api/otel/traces.js +53 -0
- package/lib/api/otel/types.d.ts +112 -0
- package/lib/api/otel/types.js +5 -0
- package/lib/api/runtimes/checkpoints.d.ts +122 -0
- package/lib/api/runtimes/checkpoints.js +118 -0
- package/lib/api/runtimes/index.d.ts +1 -0
- package/lib/api/runtimes/index.js +1 -0
- package/lib/api/runtimes/runtimes.d.ts +84 -0
- package/lib/api/runtimes/runtimes.js +50 -0
- package/lib/components/auth/Login.js +1 -1
- package/lib/components/display/BusyDots.d.ts +9 -0
- package/lib/components/display/BusyDots.js +31 -0
- package/lib/components/display/LiveRelativeTime.d.ts +10 -0
- package/lib/components/display/LiveRelativeTime.js +21 -0
- package/lib/components/display/index.d.ts +2 -0
- package/lib/components/display/index.js +2 -0
- package/lib/components/flashes/FlashSurveys.js +1 -1
- package/lib/components/index.d.ts +1 -0
- package/lib/components/index.js +1 -0
- package/lib/components/navbar/SubdomainNavBar.js +1 -1
- package/lib/components/progress/ConsumptionBar.js +6 -7
- package/lib/components/progress/CreditsIndicator.js +2 -2
- package/lib/components/progress/consumption.d.ts +12 -0
- package/lib/components/progress/consumption.js +31 -0
- package/lib/components/progress/index.d.ts +1 -0
- package/lib/components/progress/index.js +1 -0
- package/lib/components/sparklines/Sparklines.d.ts +16 -0
- package/lib/components/sparklines/Sparklines.js +65 -0
- package/lib/components/sparklines/SparklinesLine.d.ts +8 -0
- package/lib/components/sparklines/SparklinesLine.js +37 -0
- package/lib/components/sparklines/dataProcessing.d.ts +25 -0
- package/lib/components/sparklines/dataProcessing.js +35 -0
- package/lib/components/sparklines/index.d.ts +4 -0
- package/lib/components/sparklines/index.js +7 -0
- package/lib/components/sparklines/types.d.ts +36 -0
- package/lib/components/sparklines/types.js +5 -0
- package/lib/components/storage/ContentsBrowser.js +17 -1
- package/lib/components/subnav/SubNav.js +1 -1
- package/lib/config/Configuration.d.ts +4 -0
- package/lib/hooks/useCache.d.ts +6 -63
- package/lib/hooks/useCache.js +35 -205
- package/lib/hooks/useProjects.d.ts +1 -1
- package/lib/index.d.ts +2 -0
- package/lib/index.js +4 -0
- package/lib/models/ItemDTO.js +1 -1
- package/lib/models/RolesPlatform.js +2 -2
- package/lib/models/User.d.ts +2 -0
- package/lib/models/User.js +4 -1
- package/lib/otel/client/OtelClient.d.ts +93 -0
- package/lib/otel/client/OtelClient.js +232 -0
- package/lib/otel/client/index.d.ts +2 -0
- package/lib/otel/client/index.js +5 -0
- package/lib/otel/hooks/index.d.ts +186 -0
- package/lib/otel/hooks/index.js +532 -0
- package/lib/otel/index.d.ts +34 -0
- package/lib/otel/index.js +23 -0
- package/lib/otel/types.d.ts +190 -0
- package/lib/otel/types.js +5 -0
- package/lib/otel/utils.d.ts +33 -0
- package/lib/otel/utils.js +181 -0
- package/lib/otel/views/OtelLive.d.ts +12 -0
- package/lib/otel/views/OtelLive.js +372 -0
- package/lib/otel/views/OtelLogsList.d.ts +11 -0
- package/lib/otel/views/OtelLogsList.js +137 -0
- package/lib/otel/views/OtelMetricsChart.d.ts +22 -0
- package/lib/otel/views/OtelMetricsChart.js +300 -0
- package/lib/otel/views/OtelMetricsList.d.ts +15 -0
- package/lib/otel/views/OtelMetricsList.js +213 -0
- package/lib/otel/views/OtelSearchBar.d.ts +11 -0
- package/lib/otel/views/OtelSearchBar.js +22 -0
- package/lib/otel/views/OtelSpanDetail.d.ts +11 -0
- package/lib/otel/views/OtelSpanDetail.js +172 -0
- package/lib/otel/views/OtelSpanTree.d.ts +11 -0
- package/lib/otel/views/OtelSpanTree.js +176 -0
- package/lib/otel/views/OtelSqlView.d.ts +16 -0
- package/lib/otel/views/OtelSqlView.js +239 -0
- package/lib/otel/views/OtelSystemView.d.ts +15 -0
- package/lib/otel/views/OtelSystemView.js +75 -0
- package/lib/otel/views/OtelTimeline.d.ts +11 -0
- package/lib/otel/views/OtelTimeline.js +101 -0
- package/lib/otel/views/OtelTimelineRangeSlider.d.ts +16 -0
- package/lib/otel/views/OtelTimelineRangeSlider.js +338 -0
- package/lib/otel/views/OtelTracesList.d.ts +13 -0
- package/lib/otel/views/OtelTracesList.js +199 -0
- package/lib/otel/views/index.d.ts +20 -0
- package/lib/otel/views/index.js +21 -0
- package/lib/state/storage/IAMStorage.d.ts +2 -1
- package/lib/state/substates/CoreState.js +7 -6
- package/lib/utils/Date.d.ts +6 -0
- package/lib/utils/Date.js +37 -0
- package/lib/utils/Jwt.d.ts +42 -0
- package/lib/utils/Jwt.js +44 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +1 -0
- package/lib/views/iam/SignInSimple.d.ts +43 -0
- package/lib/views/iam/SignInSimple.js +113 -0
- package/lib/views/iam/index.d.ts +2 -0
- package/lib/views/iam/index.js +5 -0
- package/lib/views/iam-tokens/IAMTokenEdit.d.ts +5 -1
- package/lib/views/iam-tokens/IAMTokenEdit.js +54 -5
- package/lib/views/iam-tokens/IAMTokenNew.js +2 -2
- package/lib/views/iam-tokens/IAMTokens.d.ts +4 -2
- package/lib/views/iam-tokens/IAMTokens.js +68 -36
- package/lib/views/iam-tokens/Tokens.js +63 -31
- package/lib/views/index.d.ts +3 -1
- package/lib/views/index.js +3 -1
- package/lib/views/otel/DashboardView.d.ts +16 -0
- package/lib/views/otel/DashboardView.js +4 -0
- package/lib/views/otel/LogsView.d.ts +12 -0
- package/lib/views/otel/LogsView.js +4 -0
- package/lib/views/otel/MetricsView.d.ts +12 -0
- package/lib/views/otel/MetricsView.js +4 -0
- package/lib/views/otel/OtelHeader.d.ts +33 -0
- package/lib/views/otel/OtelHeader.js +105 -0
- package/lib/views/otel/SqlView.d.ts +9 -0
- package/lib/views/otel/SqlView.js +4 -0
- package/lib/views/otel/SystemView.d.ts +9 -0
- package/lib/views/otel/SystemView.js +4 -0
- package/lib/views/otel/TracesView.d.ts +12 -0
- package/lib/views/otel/TracesView.js +4 -0
- package/lib/views/otel/index.d.ts +16 -0
- package/lib/views/otel/index.js +12 -0
- package/lib/views/otel/simpleAuthStore.d.ts +21 -0
- package/lib/views/otel/simpleAuthStore.js +22 -0
- package/lib/views/profile/UserBadge.d.ts +20 -0
- package/lib/views/profile/UserBadge.js +101 -0
- package/lib/views/profile/index.d.ts +2 -0
- package/lib/views/profile/index.js +5 -0
- package/package.json +3 -4
package/README.md
CHANGED
package/lib/api/constants.d.ts
CHANGED
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
* API base paths for different service domains
|
|
3
3
|
*/
|
|
4
4
|
export declare const API_BASE_PATHS: {
|
|
5
|
+
readonly AI_AGENTS: "/api/ai-agents/v1";
|
|
5
6
|
readonly IAM: "/api/iam/v1";
|
|
7
|
+
readonly OTEL: "/api/otel/v1";
|
|
6
8
|
readonly RUNTIMES: "/api/runtimes/v1";
|
|
7
9
|
readonly SPACER: "/api/spacer/v1";
|
|
8
10
|
};
|
|
@@ -10,8 +12,12 @@ export declare const API_BASE_PATHS: {
|
|
|
10
12
|
* Default service URLs for the Datalayer platform
|
|
11
13
|
*/
|
|
12
14
|
export declare const DEFAULT_SERVICE_URLS: {
|
|
15
|
+
/** Default URL for AI Agents (durable agent management) service */
|
|
16
|
+
readonly AI_AGENTS: "https://prod1.datalayer.run";
|
|
13
17
|
/** Default URL for IAM (Identity and Access Management) service */
|
|
14
18
|
readonly IAM: "https://prod1.datalayer.run";
|
|
19
|
+
/** Default URL for OTEL (OpenTelemetry observability) service */
|
|
20
|
+
readonly OTEL: "https://prod1.datalayer.run";
|
|
15
21
|
/** Default URL for Runtimes service */
|
|
16
22
|
readonly RUNTIMES: "https://prod1.datalayer.run";
|
|
17
23
|
/** Default URL for Spacer (workspaces and collaboration) service */
|
package/lib/api/constants.js
CHANGED
|
@@ -6,7 +6,9 @@
|
|
|
6
6
|
* API base paths for different service domains
|
|
7
7
|
*/
|
|
8
8
|
export const API_BASE_PATHS = {
|
|
9
|
+
AI_AGENTS: '/api/ai-agents/v1',
|
|
9
10
|
IAM: '/api/iam/v1',
|
|
11
|
+
OTEL: '/api/otel/v1',
|
|
10
12
|
RUNTIMES: '/api/runtimes/v1',
|
|
11
13
|
SPACER: '/api/spacer/v1',
|
|
12
14
|
};
|
|
@@ -14,8 +16,12 @@ export const API_BASE_PATHS = {
|
|
|
14
16
|
* Default service URLs for the Datalayer platform
|
|
15
17
|
*/
|
|
16
18
|
export const DEFAULT_SERVICE_URLS = {
|
|
19
|
+
/** Default URL for AI Agents (durable agent management) service */
|
|
20
|
+
AI_AGENTS: 'https://prod1.datalayer.run',
|
|
17
21
|
/** Default URL for IAM (Identity and Access Management) service */
|
|
18
22
|
IAM: 'https://prod1.datalayer.run',
|
|
23
|
+
/** Default URL for OTEL (OpenTelemetry observability) service */
|
|
24
|
+
OTEL: 'https://prod1.datalayer.run',
|
|
19
25
|
/** Default URL for Runtimes service */
|
|
20
26
|
RUNTIMES: 'https://prod1.datalayer.run',
|
|
21
27
|
/** Default URL for Spacer (workspaces and collaboration) service */
|
package/lib/api/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
export { requestDatalayerAPI, RunResponseError, NetworkError, } from './DatalayerApi';
|
|
10
10
|
export type { IRequestDatalayerAPIOptions } from './DatalayerApi';
|
|
11
11
|
export * as iam from './iam';
|
|
12
|
+
export * as otel from './otel';
|
|
12
13
|
export * as runtimes from './runtimes';
|
|
13
14
|
export * as spacer from './spacer';
|
|
14
15
|
/**
|
package/lib/api/index.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
export { requestDatalayerAPI, RunResponseError, NetworkError, } from './DatalayerApi';
|
|
15
15
|
// Domain-organized API exports
|
|
16
16
|
export * as iam from './iam';
|
|
17
|
+
export * as otel from './otel';
|
|
17
18
|
export * as runtimes from './runtimes';
|
|
18
19
|
export * as spacer from './spacer';
|
|
19
20
|
/**
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTEL API exports.
|
|
3
|
+
*
|
|
4
|
+
* Provides organized access to OpenTelemetry observability functionality.
|
|
5
|
+
*
|
|
6
|
+
* @module api/otel
|
|
7
|
+
*/
|
|
8
|
+
export * as traces from './traces';
|
|
9
|
+
export * as metrics from './metrics';
|
|
10
|
+
export * as logs from './logs';
|
|
11
|
+
export * as services from './services';
|
|
12
|
+
export * as query from './query';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* OTEL API exports.
|
|
7
|
+
*
|
|
8
|
+
* Provides organized access to OpenTelemetry observability functionality.
|
|
9
|
+
*
|
|
10
|
+
* @module api/otel
|
|
11
|
+
*/
|
|
12
|
+
export * as traces from './traces';
|
|
13
|
+
export * as metrics from './metrics';
|
|
14
|
+
export * as logs from './logs';
|
|
15
|
+
export * as services from './services';
|
|
16
|
+
export * as query from './query';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ListLogsResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Query log records.
|
|
4
|
+
*
|
|
5
|
+
* @param token - Authentication token
|
|
6
|
+
* @param options - Query options
|
|
7
|
+
* @param options.serviceName - Filter by service name
|
|
8
|
+
* @param options.severity - Filter by severity (INFO, WARN, ERROR, etc.)
|
|
9
|
+
* @param options.traceId - Filter by trace ID
|
|
10
|
+
* @param options.limit - Maximum number of log records
|
|
11
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
12
|
+
* @returns Promise resolving to a list of log records
|
|
13
|
+
*/
|
|
14
|
+
export declare const queryLogs: (token: string, options?: {
|
|
15
|
+
serviceName?: string;
|
|
16
|
+
severity?: string;
|
|
17
|
+
traceId?: string;
|
|
18
|
+
limit?: number;
|
|
19
|
+
}, baseUrl?: string) => Promise<ListLogsResponse>;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Logs API functions for the Datalayer OTEL service.
|
|
7
|
+
*
|
|
8
|
+
* @module api/otel/logs
|
|
9
|
+
*/
|
|
10
|
+
import { requestDatalayerAPI } from '../DatalayerApi';
|
|
11
|
+
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants';
|
|
12
|
+
import { validateToken } from '../utils/validation';
|
|
13
|
+
/**
|
|
14
|
+
* Query log records.
|
|
15
|
+
*
|
|
16
|
+
* @param token - Authentication token
|
|
17
|
+
* @param options - Query options
|
|
18
|
+
* @param options.serviceName - Filter by service name
|
|
19
|
+
* @param options.severity - Filter by severity (INFO, WARN, ERROR, etc.)
|
|
20
|
+
* @param options.traceId - Filter by trace ID
|
|
21
|
+
* @param options.limit - Maximum number of log records
|
|
22
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
23
|
+
* @returns Promise resolving to a list of log records
|
|
24
|
+
*/
|
|
25
|
+
export const queryLogs = async (token, options = {}, baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
26
|
+
validateToken(token);
|
|
27
|
+
const params = new URLSearchParams();
|
|
28
|
+
if (options.serviceName)
|
|
29
|
+
params.set('service_name', options.serviceName);
|
|
30
|
+
if (options.severity)
|
|
31
|
+
params.set('severity', options.severity);
|
|
32
|
+
if (options.traceId)
|
|
33
|
+
params.set('trace_id', options.traceId);
|
|
34
|
+
if (options.limit)
|
|
35
|
+
params.set('limit', String(options.limit));
|
|
36
|
+
const queryString = params.toString();
|
|
37
|
+
const url = `${baseUrl}${API_BASE_PATHS.OTEL}/logs${queryString ? `?${queryString}` : ''}`;
|
|
38
|
+
return requestDatalayerAPI({
|
|
39
|
+
url,
|
|
40
|
+
method: 'GET',
|
|
41
|
+
token,
|
|
42
|
+
});
|
|
43
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ListMetricsResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* List available metric names.
|
|
4
|
+
*
|
|
5
|
+
* @param token - Authentication token
|
|
6
|
+
* @param options - Query options
|
|
7
|
+
* @param options.serviceName - Filter by service name
|
|
8
|
+
* @param options.limit - Maximum number of results
|
|
9
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
10
|
+
* @returns Promise resolving to a list of metrics
|
|
11
|
+
*/
|
|
12
|
+
export declare const listMetrics: (token: string, options?: {
|
|
13
|
+
serviceName?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
}, baseUrl?: string) => Promise<ListMetricsResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Query metric data points with filters.
|
|
18
|
+
*
|
|
19
|
+
* @param token - Authentication token
|
|
20
|
+
* @param options - Query options
|
|
21
|
+
* @param options.metricName - Filter by metric name
|
|
22
|
+
* @param options.serviceName - Filter by service name
|
|
23
|
+
* @param options.limit - Maximum number of data points
|
|
24
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
25
|
+
* @returns Promise resolving to metric data points
|
|
26
|
+
*/
|
|
27
|
+
export declare const queryMetrics: (token: string, options?: {
|
|
28
|
+
metricName?: string;
|
|
29
|
+
serviceName?: string;
|
|
30
|
+
limit?: number;
|
|
31
|
+
}, baseUrl?: string) => Promise<ListMetricsResponse>;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Metrics API functions for the Datalayer OTEL service.
|
|
7
|
+
*
|
|
8
|
+
* @module api/otel/metrics
|
|
9
|
+
*/
|
|
10
|
+
import { requestDatalayerAPI } from '../DatalayerApi';
|
|
11
|
+
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants';
|
|
12
|
+
import { validateToken } from '../utils/validation';
|
|
13
|
+
/**
|
|
14
|
+
* List available metric names.
|
|
15
|
+
*
|
|
16
|
+
* @param token - Authentication token
|
|
17
|
+
* @param options - Query options
|
|
18
|
+
* @param options.serviceName - Filter by service name
|
|
19
|
+
* @param options.limit - Maximum number of results
|
|
20
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
21
|
+
* @returns Promise resolving to a list of metrics
|
|
22
|
+
*/
|
|
23
|
+
export const listMetrics = async (token, options = {}, baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
24
|
+
validateToken(token);
|
|
25
|
+
const params = new URLSearchParams();
|
|
26
|
+
if (options.limit)
|
|
27
|
+
params.set('limit', String(options.limit));
|
|
28
|
+
if (options.serviceName)
|
|
29
|
+
params.set('service_name', options.serviceName);
|
|
30
|
+
const queryString = params.toString();
|
|
31
|
+
const url = `${baseUrl}${API_BASE_PATHS.OTEL}/metrics${queryString ? `?${queryString}` : ''}`;
|
|
32
|
+
return requestDatalayerAPI({
|
|
33
|
+
url,
|
|
34
|
+
method: 'GET',
|
|
35
|
+
token,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Query metric data points with filters.
|
|
40
|
+
*
|
|
41
|
+
* @param token - Authentication token
|
|
42
|
+
* @param options - Query options
|
|
43
|
+
* @param options.metricName - Filter by metric name
|
|
44
|
+
* @param options.serviceName - Filter by service name
|
|
45
|
+
* @param options.limit - Maximum number of data points
|
|
46
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
47
|
+
* @returns Promise resolving to metric data points
|
|
48
|
+
*/
|
|
49
|
+
export const queryMetrics = async (token, options = {}, baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
50
|
+
validateToken(token);
|
|
51
|
+
const params = new URLSearchParams();
|
|
52
|
+
if (options.metricName)
|
|
53
|
+
params.set('name', options.metricName);
|
|
54
|
+
if (options.serviceName)
|
|
55
|
+
params.set('service_name', options.serviceName);
|
|
56
|
+
if (options.limit)
|
|
57
|
+
params.set('limit', String(options.limit));
|
|
58
|
+
const queryString = params.toString();
|
|
59
|
+
const url = `${baseUrl}${API_BASE_PATHS.OTEL}/metrics/query${queryString ? `?${queryString}` : ''}`;
|
|
60
|
+
return requestDatalayerAPI({
|
|
61
|
+
url,
|
|
62
|
+
method: 'GET',
|
|
63
|
+
token,
|
|
64
|
+
});
|
|
65
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { QueryResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Execute an ad-hoc SQL query via the SQL Engine engine.
|
|
4
|
+
*
|
|
5
|
+
* @param token - Authentication token
|
|
6
|
+
* @param sql - SQL query string
|
|
7
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
8
|
+
* @returns Promise resolving to query results
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const result = await executeSql(token, 'SELECT * FROM spans LIMIT 10');
|
|
13
|
+
* console.log(result.data);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const executeSql: (token: string, sql: string, baseUrl?: string) => Promise<QueryResponse>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* SQL query API functions for the Datalayer OTEL service.
|
|
7
|
+
*
|
|
8
|
+
* Executes ad-hoc SQL queries via the SQL Engine engine.
|
|
9
|
+
*
|
|
10
|
+
* @module api/otel/query
|
|
11
|
+
*/
|
|
12
|
+
import { requestDatalayerAPI } from '../DatalayerApi';
|
|
13
|
+
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants';
|
|
14
|
+
import { validateToken } from '../utils/validation';
|
|
15
|
+
/**
|
|
16
|
+
* Execute an ad-hoc SQL query via the SQL Engine engine.
|
|
17
|
+
*
|
|
18
|
+
* @param token - Authentication token
|
|
19
|
+
* @param sql - SQL query string
|
|
20
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
21
|
+
* @returns Promise resolving to query results
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const result = await executeSql(token, 'SELECT * FROM spans LIMIT 10');
|
|
26
|
+
* console.log(result.data);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export const executeSql = async (token, sql, baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
30
|
+
validateToken(token);
|
|
31
|
+
return requestDatalayerAPI({
|
|
32
|
+
url: `${baseUrl}${API_BASE_PATHS.OTEL}/query`,
|
|
33
|
+
method: 'POST',
|
|
34
|
+
body: { sql },
|
|
35
|
+
token,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ListServicesResponse, OtelStats, PingResponse, VersionResponse, FlushResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* List all observed service names.
|
|
4
|
+
*
|
|
5
|
+
* @param token - Authentication token
|
|
6
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
7
|
+
* @returns Promise resolving to a list of service names
|
|
8
|
+
*/
|
|
9
|
+
export declare const listServices: (token: string, baseUrl?: string) => Promise<ListServicesResponse>;
|
|
10
|
+
/**
|
|
11
|
+
* Check service health (no auth required).
|
|
12
|
+
*
|
|
13
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
14
|
+
* @returns Promise resolving to ping response
|
|
15
|
+
*/
|
|
16
|
+
export declare const ping: (baseUrl?: string) => Promise<PingResponse>;
|
|
17
|
+
/**
|
|
18
|
+
* Get service version.
|
|
19
|
+
*
|
|
20
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
21
|
+
* @returns Promise resolving to version info
|
|
22
|
+
*/
|
|
23
|
+
export declare const version: (baseUrl?: string) => Promise<VersionResponse>;
|
|
24
|
+
/**
|
|
25
|
+
* Get storage statistics.
|
|
26
|
+
*
|
|
27
|
+
* @param token - Authentication token
|
|
28
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
29
|
+
* @returns Promise resolving to storage statistics
|
|
30
|
+
*/
|
|
31
|
+
export declare const getStats: (token: string, baseUrl?: string) => Promise<OtelStats>;
|
|
32
|
+
/**
|
|
33
|
+
* Force-flush all buffered telemetry data.
|
|
34
|
+
*
|
|
35
|
+
* @param token - Authentication token
|
|
36
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
37
|
+
* @returns Promise resolving to flush result
|
|
38
|
+
*/
|
|
39
|
+
export declare const flush: (token: string, baseUrl?: string) => Promise<FlushResponse>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Services API functions for the Datalayer OTEL service.
|
|
7
|
+
*
|
|
8
|
+
* @module api/otel/services
|
|
9
|
+
*/
|
|
10
|
+
import { requestDatalayerAPI } from '../DatalayerApi';
|
|
11
|
+
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants';
|
|
12
|
+
import { validateToken } from '../utils/validation';
|
|
13
|
+
/**
|
|
14
|
+
* List all observed service names.
|
|
15
|
+
*
|
|
16
|
+
* @param token - Authentication token
|
|
17
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
18
|
+
* @returns Promise resolving to a list of service names
|
|
19
|
+
*/
|
|
20
|
+
export const listServices = async (token, baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
21
|
+
validateToken(token);
|
|
22
|
+
return requestDatalayerAPI({
|
|
23
|
+
url: `${baseUrl}${API_BASE_PATHS.OTEL}/traces/services/list`,
|
|
24
|
+
method: 'GET',
|
|
25
|
+
token,
|
|
26
|
+
});
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Check service health (no auth required).
|
|
30
|
+
*
|
|
31
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
32
|
+
* @returns Promise resolving to ping response
|
|
33
|
+
*/
|
|
34
|
+
export const ping = async (baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
35
|
+
return requestDatalayerAPI({
|
|
36
|
+
url: `${baseUrl}${API_BASE_PATHS.OTEL}/ping`,
|
|
37
|
+
method: 'GET',
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Get service version.
|
|
42
|
+
*
|
|
43
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
44
|
+
* @returns Promise resolving to version info
|
|
45
|
+
*/
|
|
46
|
+
export const version = async (baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
47
|
+
return requestDatalayerAPI({
|
|
48
|
+
url: `${baseUrl}${API_BASE_PATHS.OTEL}/version`,
|
|
49
|
+
method: 'GET',
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* Get storage statistics.
|
|
54
|
+
*
|
|
55
|
+
* @param token - Authentication token
|
|
56
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
57
|
+
* @returns Promise resolving to storage statistics
|
|
58
|
+
*/
|
|
59
|
+
export const getStats = async (token, baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
60
|
+
validateToken(token);
|
|
61
|
+
return requestDatalayerAPI({
|
|
62
|
+
url: `${baseUrl}${API_BASE_PATHS.OTEL}/stats`,
|
|
63
|
+
method: 'GET',
|
|
64
|
+
token,
|
|
65
|
+
});
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Force-flush all buffered telemetry data.
|
|
69
|
+
*
|
|
70
|
+
* @param token - Authentication token
|
|
71
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
72
|
+
* @returns Promise resolving to flush result
|
|
73
|
+
*/
|
|
74
|
+
export const flush = async (token, baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
75
|
+
validateToken(token);
|
|
76
|
+
return requestDatalayerAPI({
|
|
77
|
+
url: `${baseUrl}${API_BASE_PATHS.OTEL}/flush`,
|
|
78
|
+
method: 'POST',
|
|
79
|
+
token,
|
|
80
|
+
});
|
|
81
|
+
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ListTracesResponse, GetTraceResponse } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* List recent traces.
|
|
4
|
+
*
|
|
5
|
+
* @param token - Authentication token
|
|
6
|
+
* @param options - Query options
|
|
7
|
+
* @param options.serviceName - Filter by service name
|
|
8
|
+
* @param options.limit - Maximum number of traces (default: 20)
|
|
9
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
10
|
+
* @returns Promise resolving to a list of trace spans
|
|
11
|
+
*/
|
|
12
|
+
export declare const listTraces: (token: string, options?: {
|
|
13
|
+
serviceName?: string;
|
|
14
|
+
limit?: number;
|
|
15
|
+
}, baseUrl?: string) => Promise<ListTracesResponse>;
|
|
16
|
+
/**
|
|
17
|
+
* Get all spans for a specific trace.
|
|
18
|
+
*
|
|
19
|
+
* @param token - Authentication token
|
|
20
|
+
* @param traceId - The trace ID to retrieve
|
|
21
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
22
|
+
* @returns Promise resolving to the trace's spans
|
|
23
|
+
*/
|
|
24
|
+
export declare const getTrace: (token: string, traceId: string, baseUrl?: string) => Promise<GetTraceResponse>;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (c) 2023-2025 Datalayer, Inc.
|
|
3
|
+
* Distributed under the terms of the Modified BSD License.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Traces API functions for the Datalayer OTEL service.
|
|
7
|
+
*
|
|
8
|
+
* @module api/otel/traces
|
|
9
|
+
*/
|
|
10
|
+
import { requestDatalayerAPI } from '../DatalayerApi';
|
|
11
|
+
import { API_BASE_PATHS, DEFAULT_SERVICE_URLS } from '../constants';
|
|
12
|
+
import { validateToken } from '../utils/validation';
|
|
13
|
+
/**
|
|
14
|
+
* List recent traces.
|
|
15
|
+
*
|
|
16
|
+
* @param token - Authentication token
|
|
17
|
+
* @param options - Query options
|
|
18
|
+
* @param options.serviceName - Filter by service name
|
|
19
|
+
* @param options.limit - Maximum number of traces (default: 20)
|
|
20
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
21
|
+
* @returns Promise resolving to a list of trace spans
|
|
22
|
+
*/
|
|
23
|
+
export const listTraces = async (token, options = {}, baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
24
|
+
validateToken(token);
|
|
25
|
+
const params = new URLSearchParams();
|
|
26
|
+
if (options.limit)
|
|
27
|
+
params.set('limit', String(options.limit));
|
|
28
|
+
if (options.serviceName)
|
|
29
|
+
params.set('service_name', options.serviceName);
|
|
30
|
+
const queryString = params.toString();
|
|
31
|
+
const url = `${baseUrl}${API_BASE_PATHS.OTEL}/traces${queryString ? `?${queryString}` : ''}`;
|
|
32
|
+
return requestDatalayerAPI({
|
|
33
|
+
url,
|
|
34
|
+
method: 'GET',
|
|
35
|
+
token,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Get all spans for a specific trace.
|
|
40
|
+
*
|
|
41
|
+
* @param token - Authentication token
|
|
42
|
+
* @param traceId - The trace ID to retrieve
|
|
43
|
+
* @param baseUrl - Base URL for the OTEL service
|
|
44
|
+
* @returns Promise resolving to the trace's spans
|
|
45
|
+
*/
|
|
46
|
+
export const getTrace = async (token, traceId, baseUrl = DEFAULT_SERVICE_URLS.OTEL) => {
|
|
47
|
+
validateToken(token);
|
|
48
|
+
return requestDatalayerAPI({
|
|
49
|
+
url: `${baseUrl}${API_BASE_PATHS.OTEL}/traces/${traceId}`,
|
|
50
|
+
method: 'GET',
|
|
51
|
+
token,
|
|
52
|
+
});
|
|
53
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TypeScript DTOs for the OTEL API.
|
|
3
|
+
*
|
|
4
|
+
* @module api/otel/types
|
|
5
|
+
*/
|
|
6
|
+
/** A single span in a trace. */
|
|
7
|
+
export interface OtelSpan {
|
|
8
|
+
trace_id: string;
|
|
9
|
+
span_id: string;
|
|
10
|
+
parent_span_id?: string;
|
|
11
|
+
span_name: string;
|
|
12
|
+
service_name: string;
|
|
13
|
+
kind: string;
|
|
14
|
+
start_time: string;
|
|
15
|
+
end_time: string;
|
|
16
|
+
duration_ms: number;
|
|
17
|
+
status_code?: string;
|
|
18
|
+
status_message?: string;
|
|
19
|
+
otel_scope_name?: string;
|
|
20
|
+
attributes?: Record<string, unknown>;
|
|
21
|
+
events?: OtelSpanEvent[];
|
|
22
|
+
links?: OtelSpanLink[];
|
|
23
|
+
}
|
|
24
|
+
/** An event attached to a span. */
|
|
25
|
+
export interface OtelSpanEvent {
|
|
26
|
+
name: string;
|
|
27
|
+
timestamp: string;
|
|
28
|
+
attributes?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
/** A link between spans. */
|
|
31
|
+
export interface OtelSpanLink {
|
|
32
|
+
trace_id: string;
|
|
33
|
+
span_id: string;
|
|
34
|
+
attributes?: Record<string, unknown>;
|
|
35
|
+
}
|
|
36
|
+
/** Response from list traces endpoint. */
|
|
37
|
+
export interface ListTracesResponse {
|
|
38
|
+
data: OtelSpan[];
|
|
39
|
+
total?: number;
|
|
40
|
+
}
|
|
41
|
+
/** Response from get single trace endpoint. */
|
|
42
|
+
export interface GetTraceResponse {
|
|
43
|
+
data: OtelSpan[];
|
|
44
|
+
trace_id: string;
|
|
45
|
+
}
|
|
46
|
+
/** A metric data point. */
|
|
47
|
+
export interface OtelMetric {
|
|
48
|
+
metric_name: string;
|
|
49
|
+
service_name: string;
|
|
50
|
+
value: number;
|
|
51
|
+
unit?: string;
|
|
52
|
+
timestamp: string;
|
|
53
|
+
attributes?: Record<string, unknown>;
|
|
54
|
+
metric_type?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Response from list/query metrics endpoint. */
|
|
57
|
+
export interface ListMetricsResponse {
|
|
58
|
+
data: OtelMetric[];
|
|
59
|
+
total?: number;
|
|
60
|
+
}
|
|
61
|
+
/** A log record. */
|
|
62
|
+
export interface OtelLog {
|
|
63
|
+
timestamp: string;
|
|
64
|
+
severity_text: string;
|
|
65
|
+
severity_number?: number;
|
|
66
|
+
body: string;
|
|
67
|
+
service_name: string;
|
|
68
|
+
trace_id?: string;
|
|
69
|
+
span_id?: string;
|
|
70
|
+
attributes?: Record<string, unknown>;
|
|
71
|
+
}
|
|
72
|
+
/** Response from query logs endpoint. */
|
|
73
|
+
export interface ListLogsResponse {
|
|
74
|
+
data: OtelLog[];
|
|
75
|
+
total?: number;
|
|
76
|
+
}
|
|
77
|
+
/** Storage statistics. */
|
|
78
|
+
export interface OtelStats {
|
|
79
|
+
spans_count?: number;
|
|
80
|
+
metrics_count?: number;
|
|
81
|
+
logs_count?: number;
|
|
82
|
+
spans_files?: number;
|
|
83
|
+
metrics_files?: number;
|
|
84
|
+
logs_files?: number;
|
|
85
|
+
data_dir?: string;
|
|
86
|
+
[key: string]: unknown;
|
|
87
|
+
}
|
|
88
|
+
/** Response from SQL query endpoint. */
|
|
89
|
+
export interface QueryResponse {
|
|
90
|
+
data: Record<string, unknown>[];
|
|
91
|
+
columns?: string[];
|
|
92
|
+
row_count?: number;
|
|
93
|
+
}
|
|
94
|
+
/** Ping/health response. */
|
|
95
|
+
export interface PingResponse {
|
|
96
|
+
status: string;
|
|
97
|
+
[key: string]: unknown;
|
|
98
|
+
}
|
|
99
|
+
/** Version response. */
|
|
100
|
+
export interface VersionResponse {
|
|
101
|
+
version: string;
|
|
102
|
+
[key: string]: unknown;
|
|
103
|
+
}
|
|
104
|
+
/** Flush response. */
|
|
105
|
+
export interface FlushResponse {
|
|
106
|
+
flushed: boolean;
|
|
107
|
+
[key: string]: unknown;
|
|
108
|
+
}
|
|
109
|
+
/** List services response. */
|
|
110
|
+
export interface ListServicesResponse {
|
|
111
|
+
services: string[];
|
|
112
|
+
}
|