@principal-ai/otel-collector-server 0.1.0
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 +252 -0
- package/dist/OTELCollectorServer.d.ts +52 -0
- package/dist/OTELCollectorServer.d.ts.map +1 -0
- package/dist/OTELCollectorServer.js +252 -0
- package/dist/OTELCollectorServer.js.map +1 -0
- package/dist/__tests__/fixtures/traces.d.ts +8 -0
- package/dist/__tests__/fixtures/traces.d.ts.map +1 -0
- package/dist/__tests__/fixtures/traces.js +186 -0
- package/dist/__tests__/fixtures/traces.js.map +1 -0
- package/dist/bin/otel-collector-server.d.ts +6 -0
- package/dist/bin/otel-collector-server.d.ts.map +1 -0
- package/dist/bin/otel-collector-server.js +132 -0
- package/dist/bin/otel-collector-server.js.map +1 -0
- package/dist/core/BinaryManager.d.ts +35 -0
- package/dist/core/BinaryManager.d.ts.map +1 -0
- package/dist/core/BinaryManager.js +143 -0
- package/dist/core/BinaryManager.js.map +1 -0
- package/dist/core/CollectorProcessManager.d.ts +60 -0
- package/dist/core/CollectorProcessManager.d.ts.map +1 -0
- package/dist/core/CollectorProcessManager.js +197 -0
- package/dist/core/CollectorProcessManager.js.map +1 -0
- package/dist/core/ConfigGenerator.d.ts +23 -0
- package/dist/core/ConfigGenerator.d.ts.map +1 -0
- package/dist/core/ConfigGenerator.js +115 -0
- package/dist/core/ConfigGenerator.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -0
- package/dist/output/ConsoleOutput.d.ts +24 -0
- package/dist/output/ConsoleOutput.d.ts.map +1 -0
- package/dist/output/ConsoleOutput.js +156 -0
- package/dist/output/ConsoleOutput.js.map +1 -0
- package/dist/output/FileOutput.d.ts +18 -0
- package/dist/output/FileOutput.d.ts.map +1 -0
- package/dist/output/FileOutput.js +88 -0
- package/dist/output/FileOutput.js.map +1 -0
- package/dist/output/MessagePortOutput.d.ts +19 -0
- package/dist/output/MessagePortOutput.d.ts.map +1 -0
- package/dist/output/MessagePortOutput.js +25 -0
- package/dist/output/MessagePortOutput.js.map +1 -0
- package/dist/output/TraceOutput.d.ts +13 -0
- package/dist/output/TraceOutput.d.ts.map +1 -0
- package/dist/output/TraceOutput.js +6 -0
- package/dist/output/TraceOutput.js.map +1 -0
- package/dist/router/PortRouter.d.ts +41 -0
- package/dist/router/PortRouter.d.ts.map +1 -0
- package/dist/router/PortRouter.js +130 -0
- package/dist/router/PortRouter.js.map +1 -0
- package/dist/server/OTLPForwardingServer.d.ts +59 -0
- package/dist/server/OTLPForwardingServer.d.ts.map +1 -0
- package/dist/server/OTLPForwardingServer.js +245 -0
- package/dist/server/OTLPForwardingServer.js.map +1 -0
- package/dist/shared/logger.d.ts +18 -0
- package/dist/shared/logger.d.ts.map +1 -0
- package/dist/shared/logger.js +59 -0
- package/dist/shared/logger.js.map +1 -0
- package/dist/shared/types.d.ts +47 -0
- package/dist/shared/types.d.ts.map +1 -0
- package/dist/shared/types.js +6 -0
- package/dist/shared/types.js.map +1 -0
- package/package.json +61 -0
package/README.md
ADDED
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# @principal-ai/otel-collector-server
|
|
2
|
+
|
|
3
|
+
Node.js wrapper around the official OpenTelemetry Collector with dual-mode support for development and Electron integration.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🚀 **Standalone Mode** - Console or file output for development and testing
|
|
8
|
+
- âš¡ **Electron Mode** - MessagePort routing to renderer windows (coming soon)
|
|
9
|
+
- 🔧 **Auto-managed Binaries** - Handles OpenTelemetry Collector binaries per platform
|
|
10
|
+
- 📊 **Pretty Printing** - Human-readable trace output
|
|
11
|
+
- 🎯 **Source Routing** - Routes traces based on origin URL
|
|
12
|
+
- 🔄 **Auto-restart** - Monitors and restarts collector on crashes
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
### Installation
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @principal-ai/otel-collector-server
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
### Standalone Mode (CLI)
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
# Install globally
|
|
26
|
+
npm install -g @principal-ai/otel-collector-server
|
|
27
|
+
|
|
28
|
+
# Start with console output
|
|
29
|
+
otel-collector-server
|
|
30
|
+
|
|
31
|
+
# Start with file output
|
|
32
|
+
otel-collector-server --output file --file ./traces.jsonl
|
|
33
|
+
|
|
34
|
+
# Custom configuration
|
|
35
|
+
otel-collector-server --port 4318 --log-level debug --pretty
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
### Programmatic Usage
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { OTELCollectorServer } from '@principal-ai/otel-collector-server';
|
|
42
|
+
|
|
43
|
+
const server = new OTELCollectorServer({
|
|
44
|
+
mode: 'standalone',
|
|
45
|
+
output: 'console',
|
|
46
|
+
prettyPrint: true,
|
|
47
|
+
otlpPort: 4318,
|
|
48
|
+
logLevel: 'info',
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
await server.start();
|
|
52
|
+
|
|
53
|
+
// Graceful shutdown
|
|
54
|
+
process.on('SIGINT', async () => {
|
|
55
|
+
await server.stop();
|
|
56
|
+
process.exit(0);
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Configuration
|
|
61
|
+
|
|
62
|
+
### Standalone Mode Options
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
interface OTELCollectorServerConfig {
|
|
66
|
+
mode: 'standalone' | 'electron';
|
|
67
|
+
otlpPort?: number; // Default: 4318
|
|
68
|
+
wrapperPort?: number; // Default: 4319
|
|
69
|
+
collectorVersion?: string; // Default: latest
|
|
70
|
+
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
71
|
+
autoStart?: boolean;
|
|
72
|
+
restartOnCrash?: boolean;
|
|
73
|
+
|
|
74
|
+
// Standalone mode
|
|
75
|
+
output?: 'console' | 'file';
|
|
76
|
+
outputFile?: string;
|
|
77
|
+
prettyPrint?: boolean;
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
## Architecture
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
External App (instrumented with OTEL SDK)
|
|
85
|
+
↓ HTTP POST /v1/traces (OTLP)
|
|
86
|
+
OpenTelemetry Collector (Go binary)
|
|
87
|
+
↓ forwards to
|
|
88
|
+
Node.js Wrapper (this package)
|
|
89
|
+
↓
|
|
90
|
+
Console Output | File Output | MessagePort (Electron)
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## CLI Options
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
Usage: otel-collector-server [options]
|
|
97
|
+
|
|
98
|
+
Options:
|
|
99
|
+
-p, --port <port> OTLP endpoint port (default: 4318)
|
|
100
|
+
--wrapper-port <port> Wrapper HTTP port (default: 4319)
|
|
101
|
+
-o, --output <type> Output type: console | file (default: console)
|
|
102
|
+
-f, --file <path> Output file path (sets output to file)
|
|
103
|
+
--pretty Pretty print console output (default: true)
|
|
104
|
+
--no-pretty Disable pretty printing
|
|
105
|
+
-l, --log-level <level> Log level: debug | info | warn | error
|
|
106
|
+
--version <version> Collector version (default: latest)
|
|
107
|
+
-h, --help Show help message
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Sending Test Traces
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Send a test trace via curl
|
|
114
|
+
curl -X POST http://localhost:4318/v1/traces \
|
|
115
|
+
-H "Content-Type: application/json" \
|
|
116
|
+
-d '{
|
|
117
|
+
"resourceSpans": [{
|
|
118
|
+
"resource": {
|
|
119
|
+
"attributes": [
|
|
120
|
+
{ "key": "service.name", "value": { "stringValue": "test-service" } },
|
|
121
|
+
{ "key": "dev.server.url", "value": { "stringValue": "http://localhost:3000" } }
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"scopeSpans": [{
|
|
125
|
+
"spans": [{
|
|
126
|
+
"traceId": "abc123",
|
|
127
|
+
"spanId": "def456",
|
|
128
|
+
"name": "test-span",
|
|
129
|
+
"kind": 2,
|
|
130
|
+
"startTimeUnixNano": "1737835200000000000",
|
|
131
|
+
"endTimeUnixNano": "1737835200150000000"
|
|
132
|
+
}]
|
|
133
|
+
}]
|
|
134
|
+
}]
|
|
135
|
+
}'
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Example Output
|
|
139
|
+
|
|
140
|
+
### Pretty Print (Default)
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
======================================================================
|
|
144
|
+
TRACE FROM http://localhost:3000
|
|
145
|
+
Received at: 2025-01-25T12:00:00.000Z
|
|
146
|
+
======================================================================
|
|
147
|
+
|
|
148
|
+
Service: web-ade
|
|
149
|
+
|
|
150
|
+
Scope: my-tracer
|
|
151
|
+
- HTTP GET /api/users (SERVER) 45.23ms [OK]
|
|
152
|
+
http.method=GET, http.status_code=200
|
|
153
|
+
└─ DB Query: SELECT * FROM users (CLIENT) 30.15ms [OK]
|
|
154
|
+
db.system=postgresql, db.statement=SELECT * FROM users
|
|
155
|
+
└─ Cache lookup (INTERNAL) 2.08ms [OK]
|
|
156
|
+
|
|
157
|
+
======================================================================
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### File Output (JSONL)
|
|
161
|
+
|
|
162
|
+
```json
|
|
163
|
+
{"timestamp":"2025-01-25T12:00:00.000Z","source":"http://localhost:3000","payload":{...}}
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## Requirements
|
|
167
|
+
|
|
168
|
+
- Node.js >= 18.19.0
|
|
169
|
+
- OpenTelemetry Collector binary (auto-downloaded or bundled)
|
|
170
|
+
|
|
171
|
+
## Supported Platforms
|
|
172
|
+
|
|
173
|
+
- macOS (Intel & Apple Silicon)
|
|
174
|
+
- Linux (x64 & ARM64)
|
|
175
|
+
- Windows (x64)
|
|
176
|
+
|
|
177
|
+
## Development
|
|
178
|
+
|
|
179
|
+
### Setup
|
|
180
|
+
|
|
181
|
+
```bash
|
|
182
|
+
# Install dependencies
|
|
183
|
+
npm install
|
|
184
|
+
|
|
185
|
+
# Download OpenTelemetry Collector binaries (required for first run)
|
|
186
|
+
npm run download-binaries
|
|
187
|
+
|
|
188
|
+
# Build
|
|
189
|
+
npm run build
|
|
190
|
+
|
|
191
|
+
# Run in dev mode
|
|
192
|
+
npm run dev:standalone
|
|
193
|
+
|
|
194
|
+
# Run tests
|
|
195
|
+
npm test
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
### Download Binaries
|
|
199
|
+
|
|
200
|
+
The package bundles OpenTelemetry Collector binaries for all platforms. To download them:
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
npm run download-binaries
|
|
204
|
+
```
|
|
205
|
+
|
|
206
|
+
This downloads ~250-350MB of binaries for:
|
|
207
|
+
- macOS (Intel & Apple Silicon)
|
|
208
|
+
- Linux (x64 & ARM64)
|
|
209
|
+
- Windows (x64)
|
|
210
|
+
|
|
211
|
+
Binaries are automatically downloaded when publishing via `prepublishOnly` hook.
|
|
212
|
+
|
|
213
|
+
## Project Status
|
|
214
|
+
|
|
215
|
+
### ✅ Completed (Phase 1 & 2)
|
|
216
|
+
- [x] Standalone mode with console output
|
|
217
|
+
- [x] Standalone mode with file output
|
|
218
|
+
- [x] Auto-managed collector binaries (platform detection)
|
|
219
|
+
- [x] Binary bundling for all platforms (v0.144.0)
|
|
220
|
+
- [x] Pretty-print trace output
|
|
221
|
+
- [x] Source URL routing
|
|
222
|
+
- [x] CLI interface
|
|
223
|
+
- [x] Comprehensive test coverage (57+ test cases)
|
|
224
|
+
- [x] TypeScript types and API exports
|
|
225
|
+
- [x] Full ESLint configuration and compliance
|
|
226
|
+
- [x] Tested and verified with live OTEL Collector
|
|
227
|
+
|
|
228
|
+
### ✅ Completed (Phase 3)
|
|
229
|
+
- [x] Integration tests with actual Go collector (14 comprehensive tests)
|
|
230
|
+
- [x] FileOutput unit tests (16 comprehensive tests)
|
|
231
|
+
|
|
232
|
+
### 📋 Roadmap (Future Phases)
|
|
233
|
+
- [ ] Electron mode with MessagePort routing (Phase 4)
|
|
234
|
+
- [ ] Desktop app integration (Phase 5)
|
|
235
|
+
- [ ] Metrics support (/v1/metrics)
|
|
236
|
+
- [ ] Logs support (/v1/logs)
|
|
237
|
+
- [ ] Custom processors configuration
|
|
238
|
+
- [ ] Multiple exporters support
|
|
239
|
+
|
|
240
|
+
## License
|
|
241
|
+
|
|
242
|
+
MIT
|
|
243
|
+
|
|
244
|
+
## Contributing
|
|
245
|
+
|
|
246
|
+
Issues and PRs welcome!
|
|
247
|
+
|
|
248
|
+
## See Also
|
|
249
|
+
|
|
250
|
+
- [DESIGN.md](./DESIGN.md) - Detailed architecture documentation
|
|
251
|
+
- [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/)
|
|
252
|
+
- [OTLP Specification](https://opentelemetry.io/docs/specs/otlp/)
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OTELCollectorServer - Main orchestrator for the OTEL collector wrapper
|
|
3
|
+
*/
|
|
4
|
+
import { OTELCollectorServerConfig, ServerStats } from './shared/types';
|
|
5
|
+
import type { MessagePort } from 'worker_threads';
|
|
6
|
+
export declare class OTELCollectorServer {
|
|
7
|
+
private logger;
|
|
8
|
+
private config;
|
|
9
|
+
private binaryManager;
|
|
10
|
+
private configGenerator;
|
|
11
|
+
private processManager;
|
|
12
|
+
private httpServer;
|
|
13
|
+
private traceOutput;
|
|
14
|
+
private portRouter;
|
|
15
|
+
private configFilePath;
|
|
16
|
+
private startTime;
|
|
17
|
+
private ready;
|
|
18
|
+
constructor(config?: Partial<OTELCollectorServerConfig>);
|
|
19
|
+
/**
|
|
20
|
+
* Start the collector server
|
|
21
|
+
*/
|
|
22
|
+
start(): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Stop the collector server
|
|
25
|
+
*/
|
|
26
|
+
stop(): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Check if server is ready
|
|
29
|
+
*/
|
|
30
|
+
isReady(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* Get server statistics
|
|
33
|
+
*/
|
|
34
|
+
getStats(): ServerStats;
|
|
35
|
+
/**
|
|
36
|
+
* Register a MessagePort for a specific window (Electron mode only)
|
|
37
|
+
*/
|
|
38
|
+
registerPort(windowId: string, sourceUrl: string, port: MessagePort): void;
|
|
39
|
+
/**
|
|
40
|
+
* Unregister a MessagePort for a specific window (Electron mode only)
|
|
41
|
+
*/
|
|
42
|
+
unregisterPort(windowId: string, sourceUrl: string): void;
|
|
43
|
+
/**
|
|
44
|
+
* Unregister all MessagePorts for a specific window (Electron mode only)
|
|
45
|
+
*/
|
|
46
|
+
unregisterWindow(windowId: string): void;
|
|
47
|
+
/**
|
|
48
|
+
* Create trace output based on configuration
|
|
49
|
+
*/
|
|
50
|
+
private createTraceOutput;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=OTELCollectorServer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OTELCollectorServer.d.ts","sourceRoot":"","sources":["../src/OTELCollectorServer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAeH,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAalD,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,aAAa,CAAgB;IACrC,OAAO,CAAC,eAAe,CAAkB;IACzC,OAAO,CAAC,cAAc,CAAwC;IAC9D,OAAO,CAAC,UAAU,CAAuB;IACzC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,cAAc,CAAS;IAC/B,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,KAAK,CAAkB;gBAEnB,MAAM,GAAE,OAAO,CAAC,yBAAyB,CAAM;IA0B3D;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAyE5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IA6B3B;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,QAAQ,IAAI,WAAW;IAcvB;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI;IAY1E;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAYzD;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAYxC;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAqB1B"}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OTELCollectorServer - Main orchestrator for the OTEL collector wrapper
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
17
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
18
|
+
}) : function(o, v) {
|
|
19
|
+
o["default"] = v;
|
|
20
|
+
});
|
|
21
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
22
|
+
var ownKeys = function(o) {
|
|
23
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
24
|
+
var ar = [];
|
|
25
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
26
|
+
return ar;
|
|
27
|
+
};
|
|
28
|
+
return ownKeys(o);
|
|
29
|
+
};
|
|
30
|
+
return function (mod) {
|
|
31
|
+
if (mod && mod.__esModule) return mod;
|
|
32
|
+
var result = {};
|
|
33
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
34
|
+
__setModuleDefault(result, mod);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
})();
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.OTELCollectorServer = void 0;
|
|
40
|
+
const path = __importStar(require("path"));
|
|
41
|
+
const os = __importStar(require("os"));
|
|
42
|
+
const fs = __importStar(require("fs"));
|
|
43
|
+
const BinaryManager_1 = require("./core/BinaryManager");
|
|
44
|
+
const ConfigGenerator_1 = require("./core/ConfigGenerator");
|
|
45
|
+
const CollectorProcessManager_1 = require("./core/CollectorProcessManager");
|
|
46
|
+
const OTLPForwardingServer_1 = require("./server/OTLPForwardingServer");
|
|
47
|
+
const ConsoleOutput_1 = require("./output/ConsoleOutput");
|
|
48
|
+
const FileOutput_1 = require("./output/FileOutput");
|
|
49
|
+
const MessagePortOutput_1 = require("./output/MessagePortOutput");
|
|
50
|
+
const PortRouter_1 = require("./router/PortRouter");
|
|
51
|
+
const logger_1 = require("./shared/logger");
|
|
52
|
+
const DEFAULT_CONFIG = {
|
|
53
|
+
mode: 'standalone',
|
|
54
|
+
otlpPort: 4318,
|
|
55
|
+
wrapperPort: 4319,
|
|
56
|
+
logLevel: 'info',
|
|
57
|
+
autoStart: true,
|
|
58
|
+
restartOnCrash: true,
|
|
59
|
+
output: 'console',
|
|
60
|
+
prettyPrint: true,
|
|
61
|
+
};
|
|
62
|
+
class OTELCollectorServer {
|
|
63
|
+
constructor(config = {}) {
|
|
64
|
+
this.processManager = null;
|
|
65
|
+
this.portRouter = null; // Only used in Electron mode
|
|
66
|
+
this.startTime = 0;
|
|
67
|
+
this.ready = false;
|
|
68
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
69
|
+
this.logger = (0, logger_1.createLogger)('OTELCollectorServer', this.config.logLevel);
|
|
70
|
+
this.logger.info(`Initializing in ${this.config.mode} mode`);
|
|
71
|
+
// Initialize trace output based on mode
|
|
72
|
+
this.traceOutput = this.createTraceOutput();
|
|
73
|
+
// Initialize components
|
|
74
|
+
this.binaryManager = new BinaryManager_1.BinaryManager(this.config.collectorVersion, this.logger.createChild('BinaryManager'), this.config.binaryPath);
|
|
75
|
+
this.configGenerator = new ConfigGenerator_1.ConfigGenerator(this.logger.createChild('ConfigGenerator'));
|
|
76
|
+
this.httpServer = new OTLPForwardingServer_1.OTLPForwardingServer({ port: this.config.wrapperPort, enableCORS: true }, this.traceOutput, this.logger.createChild('HTTPServer'));
|
|
77
|
+
// Config file path
|
|
78
|
+
this.configFilePath = path.join(os.tmpdir(), `otel-collector-config-${Date.now()}.yaml`);
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Start the collector server
|
|
82
|
+
*/
|
|
83
|
+
async start() {
|
|
84
|
+
this.logger.info('Starting OTEL Collector Server...');
|
|
85
|
+
this.startTime = Date.now();
|
|
86
|
+
try {
|
|
87
|
+
// 1. Ensure binary exists
|
|
88
|
+
this.logger.info('Step 1/4: Checking collector binary...');
|
|
89
|
+
const binaryPath = await this.binaryManager.ensureBinary();
|
|
90
|
+
this.logger.info(`Binary found: ${binaryPath}`);
|
|
91
|
+
// 2. Generate config
|
|
92
|
+
this.logger.info('Step 2/4: Generating collector config...');
|
|
93
|
+
await this.configGenerator.writeConfig({
|
|
94
|
+
otlpPort: this.config.otlpPort,
|
|
95
|
+
wrapperPort: this.config.wrapperPort,
|
|
96
|
+
logLevel: this.config.logLevel,
|
|
97
|
+
}, this.configFilePath);
|
|
98
|
+
this.logger.info(`Config written: ${this.configFilePath}`);
|
|
99
|
+
// 3. Start HTTP server
|
|
100
|
+
this.logger.info('Step 3/4: Starting HTTP server...');
|
|
101
|
+
await this.httpServer.start();
|
|
102
|
+
// 4. Start collector process
|
|
103
|
+
this.logger.info('Step 4/4: Starting collector process...');
|
|
104
|
+
this.processManager = new CollectorProcessManager_1.CollectorProcessManager({
|
|
105
|
+
binaryPath,
|
|
106
|
+
configPath: this.configFilePath,
|
|
107
|
+
maxRestartAttempts: this.config.restartOnCrash ? 3 : 0,
|
|
108
|
+
}, this.logger.createChild('ProcessManager'));
|
|
109
|
+
// Set up event listeners
|
|
110
|
+
this.processManager.on('ready', () => {
|
|
111
|
+
this.ready = true;
|
|
112
|
+
this.logger.info('✓ Collector ready!');
|
|
113
|
+
});
|
|
114
|
+
this.processManager.on('exit', (code) => {
|
|
115
|
+
this.logger.warn(`Collector exited with code ${code}`);
|
|
116
|
+
this.ready = false;
|
|
117
|
+
});
|
|
118
|
+
this.processManager.on('error', (err) => {
|
|
119
|
+
this.logger.error('Collector error:', err);
|
|
120
|
+
});
|
|
121
|
+
await this.processManager.start();
|
|
122
|
+
this.logger.info('');
|
|
123
|
+
this.logger.info('='.repeat(70));
|
|
124
|
+
this.logger.info('OTEL Collector Server Started Successfully!');
|
|
125
|
+
this.logger.info('='.repeat(70));
|
|
126
|
+
this.logger.info(`Mode: ${this.config.mode}`);
|
|
127
|
+
this.logger.info(`OTLP Endpoint: http://localhost:${this.config.otlpPort}`);
|
|
128
|
+
this.logger.info(`Wrapper Endpoint: http://localhost:${this.config.wrapperPort}`);
|
|
129
|
+
if (this.config.mode === 'standalone') {
|
|
130
|
+
this.logger.info(`Output: ${this.config.output}${this.config.outputFile ? ` (${this.config.outputFile})` : ''}`);
|
|
131
|
+
}
|
|
132
|
+
this.logger.info('='.repeat(70));
|
|
133
|
+
this.logger.info('');
|
|
134
|
+
}
|
|
135
|
+
catch (err) {
|
|
136
|
+
this.logger.error('Failed to start:', err);
|
|
137
|
+
await this.stop();
|
|
138
|
+
throw err;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Stop the collector server
|
|
143
|
+
*/
|
|
144
|
+
async stop() {
|
|
145
|
+
this.logger.info('Stopping OTEL Collector Server...');
|
|
146
|
+
// Stop process manager
|
|
147
|
+
if (this.processManager) {
|
|
148
|
+
await this.processManager.stop();
|
|
149
|
+
this.processManager = null;
|
|
150
|
+
}
|
|
151
|
+
// Stop HTTP server
|
|
152
|
+
await this.httpServer.stop();
|
|
153
|
+
// Close file output if used
|
|
154
|
+
if (this.traceOutput instanceof FileOutput_1.FileOutput) {
|
|
155
|
+
await this.traceOutput.close();
|
|
156
|
+
}
|
|
157
|
+
// Clean up config file
|
|
158
|
+
try {
|
|
159
|
+
await fs.promises.unlink(this.configFilePath);
|
|
160
|
+
this.logger.debug(`Removed config file: ${this.configFilePath}`);
|
|
161
|
+
}
|
|
162
|
+
catch (err) {
|
|
163
|
+
// Ignore
|
|
164
|
+
}
|
|
165
|
+
this.ready = false;
|
|
166
|
+
this.logger.info('Stopped');
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Check if server is ready
|
|
170
|
+
*/
|
|
171
|
+
isReady() {
|
|
172
|
+
return this.ready;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get server statistics
|
|
176
|
+
*/
|
|
177
|
+
getStats() {
|
|
178
|
+
return {
|
|
179
|
+
tracesReceived: this.httpServer.getTracesReceived(),
|
|
180
|
+
tracesForwarded: this.httpServer.getTracesReceived(), // Same for now
|
|
181
|
+
activeRegistrations: this.portRouter?.getRegistrationCount() || 0,
|
|
182
|
+
collectorStatus: this.processManager?.getStats() || {
|
|
183
|
+
uptime: 0,
|
|
184
|
+
restartCount: 0,
|
|
185
|
+
status: 'stopped',
|
|
186
|
+
},
|
|
187
|
+
uptime: this.startTime > 0 ? Date.now() - this.startTime : 0,
|
|
188
|
+
};
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Register a MessagePort for a specific window (Electron mode only)
|
|
192
|
+
*/
|
|
193
|
+
registerPort(windowId, sourceUrl, port) {
|
|
194
|
+
if (this.config.mode !== 'electron') {
|
|
195
|
+
throw new Error('registerPort() is only available in Electron mode');
|
|
196
|
+
}
|
|
197
|
+
if (!this.portRouter) {
|
|
198
|
+
throw new Error('Port router not initialized');
|
|
199
|
+
}
|
|
200
|
+
this.portRouter.registerPort(windowId, sourceUrl, port);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Unregister a MessagePort for a specific window (Electron mode only)
|
|
204
|
+
*/
|
|
205
|
+
unregisterPort(windowId, sourceUrl) {
|
|
206
|
+
if (this.config.mode !== 'electron') {
|
|
207
|
+
throw new Error('unregisterPort() is only available in Electron mode');
|
|
208
|
+
}
|
|
209
|
+
if (!this.portRouter) {
|
|
210
|
+
throw new Error('Port router not initialized');
|
|
211
|
+
}
|
|
212
|
+
this.portRouter.unregisterPort(windowId, sourceUrl);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Unregister all MessagePorts for a specific window (Electron mode only)
|
|
216
|
+
*/
|
|
217
|
+
unregisterWindow(windowId) {
|
|
218
|
+
if (this.config.mode !== 'electron') {
|
|
219
|
+
throw new Error('unregisterWindow() is only available in Electron mode');
|
|
220
|
+
}
|
|
221
|
+
if (!this.portRouter) {
|
|
222
|
+
throw new Error('Port router not initialized');
|
|
223
|
+
}
|
|
224
|
+
this.portRouter.unregisterWindow(windowId);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Create trace output based on configuration
|
|
228
|
+
*/
|
|
229
|
+
createTraceOutput() {
|
|
230
|
+
if (this.config.mode === 'standalone') {
|
|
231
|
+
if (this.config.output === 'file') {
|
|
232
|
+
const filePath = this.config.outputFile || './traces.jsonl';
|
|
233
|
+
this.logger.info(`Output: File (${filePath})`);
|
|
234
|
+
return new FileOutput_1.FileOutput(filePath, this.logger.createChild('FileOutput'));
|
|
235
|
+
}
|
|
236
|
+
else {
|
|
237
|
+
this.logger.info(`Output: Console (pretty: ${this.config.prettyPrint})`);
|
|
238
|
+
return new ConsoleOutput_1.ConsoleOutput({
|
|
239
|
+
prettyPrint: this.config.prettyPrint,
|
|
240
|
+
showResource: true,
|
|
241
|
+
showEvents: false,
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
// Electron mode - use MessagePort routing
|
|
246
|
+
this.logger.info('Output: MessagePort (Electron mode)');
|
|
247
|
+
this.portRouter = new PortRouter_1.PortRouter(this.logger.createChild('PortRouter'));
|
|
248
|
+
return new MessagePortOutput_1.MessagePortOutput(this.portRouter);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
exports.OTELCollectorServer = OTELCollectorServer;
|
|
252
|
+
//# sourceMappingURL=OTELCollectorServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OTELCollectorServer.js","sourceRoot":"","sources":["../src/OTELCollectorServer.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,2CAA6B;AAC7B,uCAAyB;AACzB,uCAAyB;AACzB,wDAAqD;AACrD,4DAAyD;AACzD,4EAAyE;AACzE,wEAAqE;AAErE,0DAAuD;AACvD,oDAAiD;AACjD,kEAA+D;AAC/D,oDAAiD;AACjD,4CAAuD;AAIvD,MAAM,cAAc,GAAuC;IACzD,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,IAAI;IACf,cAAc,EAAE,IA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,GAAG,CAAC,CAAC;gBAC/C,OAAO,IAAI,uBAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;YACzE,CAAC;iBAAM,CAAC;gBACN,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,IAAI,CAAC,MAAM,CAAC,WAAW,GAAG,CAAC,CAAC;gBACzE,OAAO,IAAI,6BAAa,CAAC;oBACvB,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,WAAW;oBACpC,YAAY,EAAE,IAAI;oBAClB,UAAU,EAAE,KAAK;iBAClB,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,0CAA0C;QAC1C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,qCAAqC,CAAC,CAAC;QACxD,IAAI,CAAC,UAAU,GAAG,IAAI,uBAAU,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;QACxE,OAAO,IAAI,qCAAiB,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAChD,CAAC;CACF;AAhPD,kDAgPC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Test fixtures for OTLP trace data
|
|
3
|
+
*/
|
|
4
|
+
import { IExportTraceServiceRequest } from '@opentelemetry/otlp-transformer';
|
|
5
|
+
export declare const createMockTrace: (overrides?: Partial<IExportTraceServiceRequest>) => IExportTraceServiceRequest;
|
|
6
|
+
export declare const createNestedMockTrace: () => IExportTraceServiceRequest;
|
|
7
|
+
export declare const createErrorTrace: () => IExportTraceServiceRequest;
|
|
8
|
+
//# sourceMappingURL=traces.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"traces.d.ts","sourceRoot":"","sources":["../../../src/__tests__/fixtures/traces.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAE7E,eAAO,MAAM,eAAe,GAAI,YAAY,OAAO,CAAC,0BAA0B,CAAC,KAAG,0BA+CjF,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAAO,0BA4ExC,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAO,0BAkDnC,CAAC"}
|