@cloudbase/agent-observability 1.0.1-alpha.10

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.
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Observability configuration types for AG-Kit Server.
3
+ *
4
+ * Provides a unified configuration interface for trace exporters:
5
+ * - Console: Development/debugging output
6
+ * - OTLP: Production export to Langfuse, Jaeger, etc.
7
+ * - Custom: User-defined setup logic
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ /**
12
+ * Trace exporter type constants.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { ExporterType } from '@cloudbase/agent-observability/server';
17
+ *
18
+ * { type: ExporterType.Console }
19
+ * { type: ExporterType.OTLP }
20
+ * { type: ExporterType.Custom }
21
+ * ```
22
+ *
23
+ * @public
24
+ */
25
+ declare const ExporterType: {
26
+ /** Console exporter - outputs traces to stdout */
27
+ readonly Console: "console";
28
+ /** OTLP exporter - sends traces to OTLP-compatible backend */
29
+ readonly OTLP: "otlp";
30
+ /** Custom exporter - user-defined setup logic */
31
+ readonly Custom: "custom";
32
+ };
33
+ /**
34
+ * Trace exporter type literal values.
35
+ *
36
+ * @public
37
+ */
38
+ type ExporterType = typeof ExporterType[keyof typeof ExporterType];
39
+ /**
40
+ * Batch processing configuration for span exporters.
41
+ *
42
+ * Used by BatchSpanProcessor to optimize performance:
43
+ * - Collects spans in memory and exports them in batches
44
+ * - Reduces I/O operations (console) or network requests (OTLP)
45
+ * - Recommended for production environments
46
+ *
47
+ * @public
48
+ */
49
+ interface BatchConfig {
50
+ /** Maximum number of spans per export batch (default: 100) */
51
+ maxExportBatchSize?: number;
52
+ /** Maximum delay in milliseconds before exporting (default: 5000) */
53
+ scheduledDelayMillis?: number;
54
+ /** Maximum queue size (default: 2048) */
55
+ maxQueueSize?: number;
56
+ /** Export timeout in milliseconds (default: 30000) */
57
+ exportTimeoutMillis?: number;
58
+ }
59
+ /**
60
+ * Console trace exporter configuration.
61
+ *
62
+ * Outputs traces to stdout in JSON format using ConsoleSpanExporter.
63
+ * Useful for development and debugging.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * import { ExporterType } from '@cloudbase/agent-observability/server';
68
+ *
69
+ * { type: ExporterType.Console }
70
+ * { type: ExporterType.Console, batch: { maxExportBatchSize: 200 } }
71
+ * ```
72
+ *
73
+ * @public
74
+ */
75
+ interface ConsoleTraceConfig {
76
+ /** Discriminator for console exporter */
77
+ type: typeof ExporterType.Console;
78
+ /** Optional batch processing configuration */
79
+ batch?: BatchConfig;
80
+ }
81
+ /**
82
+ * OTLP trace exporter configuration.
83
+ *
84
+ * Exports traces via OTLP protocol to any compatible backend:
85
+ * - Langfuse: https://cloud.langfuse.com/api/public/otlp/v1/traces
86
+ * - Jaeger: http://localhost:4318/v1/traces
87
+ * - OTel Collector: custom endpoint
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { ExporterType } from '@cloudbase/agent-observability/server';
92
+ *
93
+ * {
94
+ * type: ExporterType.OTLP,
95
+ * url: 'https://cloud.langfuse.com/api/public/otlp/v1/traces',
96
+ * headers: {
97
+ * 'Authorization': 'Basic ' + btoa('pk-lf-xxx:sk-lf-xxx')
98
+ * }
99
+ * }
100
+ * ```
101
+ *
102
+ * @public
103
+ */
104
+ interface OTLPTraceConfig {
105
+ /** Discriminator for OTLP exporter */
106
+ type: typeof ExporterType.OTLP;
107
+ /** OTLP endpoint URL (http/https) */
108
+ url: string;
109
+ /** Optional HTTP headers for authentication */
110
+ headers?: Record<string, string>;
111
+ /** Request timeout in milliseconds (default: 10000) */
112
+ timeout?: number;
113
+ /** Optional batch processing configuration */
114
+ batch?: BatchConfig;
115
+ }
116
+ /**
117
+ * Custom trace exporter configuration.
118
+ *
119
+ * Allows users to provide custom trace setup logic.
120
+ * Useful for integrations not covered by console/otlp.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * import { ExporterType } from '@cloudbase/agent-observability/server';
125
+ *
126
+ * {
127
+ * type: ExporterType.Custom,
128
+ * setup: async () => {
129
+ * const exporter = new MyCustomExporter();
130
+ * const provider = new BasicTracerProvider();
131
+ * provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
132
+ * provider.register();
133
+ * }
134
+ * }
135
+ * ```
136
+ *
137
+ * @public
138
+ */
139
+ interface CustomTraceConfig {
140
+ /** Discriminator for custom setup */
141
+ type: typeof ExporterType.Custom;
142
+ /** User-defined setup function */
143
+ setup: () => Promise<void> | void;
144
+ }
145
+ /**
146
+ * Union type of all supported trace exporter configurations.
147
+ *
148
+ * @public
149
+ */
150
+ type ObservabilityConfig = ConsoleTraceConfig | OTLPTraceConfig | CustomTraceConfig;
151
+
152
+ /**
153
+ * Observability setup implementation for AG-Kit Server.
154
+ *
155
+ * Merges configuration from environment variables and parameters,
156
+ * then applies each exporter configuration.
157
+ *
158
+ * @packageDocumentation
159
+ */
160
+
161
+ declare function setupObservability(configs?: ObservabilityConfig | ObservabilityConfig[]): Promise<void>;
162
+
163
+ export { type BatchConfig, type ConsoleTraceConfig, type CustomTraceConfig, ExporterType, type OTLPTraceConfig, type ObservabilityConfig, setupObservability };
@@ -0,0 +1,163 @@
1
+ /**
2
+ * Observability configuration types for AG-Kit Server.
3
+ *
4
+ * Provides a unified configuration interface for trace exporters:
5
+ * - Console: Development/debugging output
6
+ * - OTLP: Production export to Langfuse, Jaeger, etc.
7
+ * - Custom: User-defined setup logic
8
+ *
9
+ * @packageDocumentation
10
+ */
11
+ /**
12
+ * Trace exporter type constants.
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * import { ExporterType } from '@cloudbase/agent-observability/server';
17
+ *
18
+ * { type: ExporterType.Console }
19
+ * { type: ExporterType.OTLP }
20
+ * { type: ExporterType.Custom }
21
+ * ```
22
+ *
23
+ * @public
24
+ */
25
+ declare const ExporterType: {
26
+ /** Console exporter - outputs traces to stdout */
27
+ readonly Console: "console";
28
+ /** OTLP exporter - sends traces to OTLP-compatible backend */
29
+ readonly OTLP: "otlp";
30
+ /** Custom exporter - user-defined setup logic */
31
+ readonly Custom: "custom";
32
+ };
33
+ /**
34
+ * Trace exporter type literal values.
35
+ *
36
+ * @public
37
+ */
38
+ type ExporterType = typeof ExporterType[keyof typeof ExporterType];
39
+ /**
40
+ * Batch processing configuration for span exporters.
41
+ *
42
+ * Used by BatchSpanProcessor to optimize performance:
43
+ * - Collects spans in memory and exports them in batches
44
+ * - Reduces I/O operations (console) or network requests (OTLP)
45
+ * - Recommended for production environments
46
+ *
47
+ * @public
48
+ */
49
+ interface BatchConfig {
50
+ /** Maximum number of spans per export batch (default: 100) */
51
+ maxExportBatchSize?: number;
52
+ /** Maximum delay in milliseconds before exporting (default: 5000) */
53
+ scheduledDelayMillis?: number;
54
+ /** Maximum queue size (default: 2048) */
55
+ maxQueueSize?: number;
56
+ /** Export timeout in milliseconds (default: 30000) */
57
+ exportTimeoutMillis?: number;
58
+ }
59
+ /**
60
+ * Console trace exporter configuration.
61
+ *
62
+ * Outputs traces to stdout in JSON format using ConsoleSpanExporter.
63
+ * Useful for development and debugging.
64
+ *
65
+ * @example
66
+ * ```typescript
67
+ * import { ExporterType } from '@cloudbase/agent-observability/server';
68
+ *
69
+ * { type: ExporterType.Console }
70
+ * { type: ExporterType.Console, batch: { maxExportBatchSize: 200 } }
71
+ * ```
72
+ *
73
+ * @public
74
+ */
75
+ interface ConsoleTraceConfig {
76
+ /** Discriminator for console exporter */
77
+ type: typeof ExporterType.Console;
78
+ /** Optional batch processing configuration */
79
+ batch?: BatchConfig;
80
+ }
81
+ /**
82
+ * OTLP trace exporter configuration.
83
+ *
84
+ * Exports traces via OTLP protocol to any compatible backend:
85
+ * - Langfuse: https://cloud.langfuse.com/api/public/otlp/v1/traces
86
+ * - Jaeger: http://localhost:4318/v1/traces
87
+ * - OTel Collector: custom endpoint
88
+ *
89
+ * @example
90
+ * ```typescript
91
+ * import { ExporterType } from '@cloudbase/agent-observability/server';
92
+ *
93
+ * {
94
+ * type: ExporterType.OTLP,
95
+ * url: 'https://cloud.langfuse.com/api/public/otlp/v1/traces',
96
+ * headers: {
97
+ * 'Authorization': 'Basic ' + btoa('pk-lf-xxx:sk-lf-xxx')
98
+ * }
99
+ * }
100
+ * ```
101
+ *
102
+ * @public
103
+ */
104
+ interface OTLPTraceConfig {
105
+ /** Discriminator for OTLP exporter */
106
+ type: typeof ExporterType.OTLP;
107
+ /** OTLP endpoint URL (http/https) */
108
+ url: string;
109
+ /** Optional HTTP headers for authentication */
110
+ headers?: Record<string, string>;
111
+ /** Request timeout in milliseconds (default: 10000) */
112
+ timeout?: number;
113
+ /** Optional batch processing configuration */
114
+ batch?: BatchConfig;
115
+ }
116
+ /**
117
+ * Custom trace exporter configuration.
118
+ *
119
+ * Allows users to provide custom trace setup logic.
120
+ * Useful for integrations not covered by console/otlp.
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * import { ExporterType } from '@cloudbase/agent-observability/server';
125
+ *
126
+ * {
127
+ * type: ExporterType.Custom,
128
+ * setup: async () => {
129
+ * const exporter = new MyCustomExporter();
130
+ * const provider = new BasicTracerProvider();
131
+ * provider.addSpanProcessor(new SimpleSpanProcessor(exporter));
132
+ * provider.register();
133
+ * }
134
+ * }
135
+ * ```
136
+ *
137
+ * @public
138
+ */
139
+ interface CustomTraceConfig {
140
+ /** Discriminator for custom setup */
141
+ type: typeof ExporterType.Custom;
142
+ /** User-defined setup function */
143
+ setup: () => Promise<void> | void;
144
+ }
145
+ /**
146
+ * Union type of all supported trace exporter configurations.
147
+ *
148
+ * @public
149
+ */
150
+ type ObservabilityConfig = ConsoleTraceConfig | OTLPTraceConfig | CustomTraceConfig;
151
+
152
+ /**
153
+ * Observability setup implementation for AG-Kit Server.
154
+ *
155
+ * Merges configuration from environment variables and parameters,
156
+ * then applies each exporter configuration.
157
+ *
158
+ * @packageDocumentation
159
+ */
160
+
161
+ declare function setupObservability(configs?: ObservabilityConfig | ObservabilityConfig[]): Promise<void>;
162
+
163
+ export { type BatchConfig, type ConsoleTraceConfig, type CustomTraceConfig, ExporterType, type OTLPTraceConfig, type ObservabilityConfig, setupObservability };