@principal-ai/otel-collector-server 0.1.8 → 0.2.1
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 +92 -3
- package/dist/OTELCollectorServer.d.ts +3 -2
- package/dist/OTELCollectorServer.d.ts.map +1 -1
- package/dist/OTELCollectorServer.js +57 -19
- package/dist/OTELCollectorServer.js.map +1 -1
- package/dist/bin/otel-collector-server.js +110 -17
- package/dist/bin/otel-collector-server.js.map +1 -1
- package/dist/core/ConfigGenerator.d.ts +5 -1
- package/dist/core/ConfigGenerator.d.ts.map +1 -1
- package/dist/core/ConfigGenerator.js +43 -3
- package/dist/core/ConfigGenerator.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/output/FileOutput.d.ts +30 -4
- package/dist/output/FileOutput.d.ts.map +1 -1
- package/dist/output/FileOutput.js +150 -18
- package/dist/output/FileOutput.js.map +1 -1
- package/dist/output/TraceOutput.d.ts +17 -0
- package/dist/output/TraceOutput.d.ts.map +1 -1
- package/dist/router/HTTPRouter.d.ts +38 -0
- package/dist/router/HTTPRouter.d.ts.map +1 -0
- package/dist/router/HTTPRouter.js +179 -0
- package/dist/router/HTTPRouter.js.map +1 -0
- package/dist/router/PortRouter.d.ts +9 -9
- package/dist/router/PortRouter.d.ts.map +1 -1
- package/dist/router/PortRouter.js +39 -39
- package/dist/router/PortRouter.js.map +1 -1
- package/dist/server/OTLPForwardingServer.d.ts +33 -2
- package/dist/server/OTLPForwardingServer.d.ts.map +1 -1
- package/dist/server/OTLPForwardingServer.js +298 -20
- package/dist/server/OTLPForwardingServer.js.map +1 -1
- package/dist/shared/ServiceStats.d.ts +66 -0
- package/dist/shared/ServiceStats.d.ts.map +1 -0
- package/dist/shared/ServiceStats.js +144 -0
- package/dist/shared/ServiceStats.js.map +1 -0
- package/dist/shared/VersionRegistryClient.d.ts +53 -0
- package/dist/shared/VersionRegistryClient.d.ts.map +1 -0
- package/dist/shared/VersionRegistryClient.js +132 -0
- package/dist/shared/VersionRegistryClient.js.map +1 -0
- package/dist/shared/types.d.ts +39 -1
- package/dist/shared/types.d.ts.map +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -2,10 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
Node.js wrapper around the official OpenTelemetry Collector with dual-mode support for development and Electron integration.
|
|
4
4
|
|
|
5
|
+
## 🎯 Contract-Based Observability (Coming Soon)
|
|
6
|
+
|
|
7
|
+
This package is being enhanced to support **contract-based observability** - validate traces against expected workflows, reduce storage costs by 90%+, and surface unknown-unknowns automatically.
|
|
8
|
+
|
|
9
|
+
**Key Features:**
|
|
10
|
+
- ✅ Validate traces against Principal-View canvas contracts
|
|
11
|
+
- ✅ Emit metrics-only for expected workflows (95% of traces)
|
|
12
|
+
- ✅ Store full traces only for anomalies (5% of traces)
|
|
13
|
+
- ✅ Real-time contract violations in Electron UI
|
|
14
|
+
- ✅ Production mode for EC2 deployment
|
|
15
|
+
|
|
16
|
+
See [CONTRACT-BASED-PLATFORM.md](./docs/architecture/CONTRACT-BASED-PLATFORM.md) for full design.
|
|
17
|
+
|
|
5
18
|
## Features
|
|
6
19
|
|
|
7
20
|
- 🚀 **Standalone Mode** - Console or file output for development and testing
|
|
8
|
-
- ⚡ **Electron Mode** - MessagePort routing to renderer windows
|
|
21
|
+
- ⚡ **Electron Mode** - MessagePort routing to renderer windows
|
|
9
22
|
- 🔧 **Auto-managed Binaries** - Handles OpenTelemetry Collector binaries per platform
|
|
10
23
|
- 📊 **Pretty Printing** - Human-readable trace output
|
|
11
24
|
- 🎯 **Source Routing** - Routes traces based on origin URL
|
|
@@ -33,8 +46,28 @@ otel-collector-server --output file --file ./traces.jsonl
|
|
|
33
46
|
|
|
34
47
|
# Custom configuration
|
|
35
48
|
otel-collector-server --port 4318 --log-level debug --pretty
|
|
49
|
+
|
|
50
|
+
# Using environment variables
|
|
51
|
+
OTLP_PORT=4318 OUTPUT=file OUTPUT_FILE=./traces.jsonl otel-collector-server
|
|
36
52
|
```
|
|
37
53
|
|
|
54
|
+
### Production Deployment
|
|
55
|
+
|
|
56
|
+
**AWS App Runner (Recommended)** - Serverless, managed deployment:
|
|
57
|
+
- ✅ **Currently deployed**: https://5hmsn3wzue.us-east-1.awsapprunner.com
|
|
58
|
+
- 📋 **Architecture & Decisions**: [production-deployment.md](./.principal-views/production-deployment.md)
|
|
59
|
+
- 🔧 **Operational Guide**: [PRODUCTION.md](./docs/deployment/PRODUCTION.md)
|
|
60
|
+
- 🚀 **Setup Guide**: [APPRUNNER-SETUP.md](./docs/deployment/APPRUNNER-SETUP.md)
|
|
61
|
+
- Automatic deployments via GitHub Actions (push to `main` branch)
|
|
62
|
+
- Auto-scaling and zero-downtime updates
|
|
63
|
+
- ~$51-60/month for 24/7 operation
|
|
64
|
+
|
|
65
|
+
**AWS EC2** - Self-hosted for more control:
|
|
66
|
+
- See **[DEPLOYMENT.md](./docs/deployment/DEPLOYMENT.md)** for complete guide
|
|
67
|
+
- Docker or PM2 deployment options
|
|
68
|
+
- Manual deployment and management
|
|
69
|
+
- ~$15/month for t3.small instance
|
|
70
|
+
|
|
38
71
|
### Programmatic Usage
|
|
39
72
|
|
|
40
73
|
```typescript
|
|
@@ -61,6 +94,24 @@ process.on('SIGINT', async () => {
|
|
|
61
94
|
|
|
62
95
|
### Standalone Mode Options
|
|
63
96
|
|
|
97
|
+
The server can be configured via:
|
|
98
|
+
1. **Environment variables** (recommended for production)
|
|
99
|
+
2. **Command-line arguments** (overrides environment variables)
|
|
100
|
+
3. **Programmatic config** (for library usage)
|
|
101
|
+
|
|
102
|
+
**Environment Variables:**
|
|
103
|
+
```bash
|
|
104
|
+
OTLP_PORT=4318 # OTLP endpoint port
|
|
105
|
+
WRAPPER_PORT=4319 # Wrapper HTTP port
|
|
106
|
+
OUTPUT=console # Output type: console | file
|
|
107
|
+
OUTPUT_FILE=./traces.jsonl # File path (when OUTPUT=file)
|
|
108
|
+
PRETTY_PRINT=true # Pretty print console output
|
|
109
|
+
LOG_LEVEL=info # Log level: debug | info | warn | error
|
|
110
|
+
COLLECTOR_VERSION=v0.144.0 # OTEL collector version
|
|
111
|
+
BINARY_PATH=/path/to/binary # Custom binary path
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**TypeScript Interface:**
|
|
64
115
|
```typescript
|
|
65
116
|
interface OTELCollectorServerConfig {
|
|
66
117
|
mode: 'standalone' | 'electron';
|
|
@@ -75,6 +126,9 @@ interface OTELCollectorServerConfig {
|
|
|
75
126
|
output?: 'console' | 'file';
|
|
76
127
|
outputFile?: string;
|
|
77
128
|
prettyPrint?: boolean;
|
|
129
|
+
|
|
130
|
+
// Optional custom binary path
|
|
131
|
+
binaryPath?: string;
|
|
78
132
|
}
|
|
79
133
|
```
|
|
80
134
|
|
|
@@ -109,8 +163,38 @@ Options:
|
|
|
109
163
|
|
|
110
164
|
## Sending Test Traces
|
|
111
165
|
|
|
166
|
+
### Production Endpoint (App Runner)
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
# Send a test trace to production
|
|
170
|
+
curl -X POST https://5hmsn3wzue.us-east-1.awsapprunner.com/v1/traces \
|
|
171
|
+
-H "Content-Type: application/json" \
|
|
172
|
+
-d '{
|
|
173
|
+
"resourceSpans": [{
|
|
174
|
+
"resource": {
|
|
175
|
+
"attributes": [
|
|
176
|
+
{ "key": "service.name", "value": { "stringValue": "test-service" } },
|
|
177
|
+
{ "key": "dev.server.url", "value": { "stringValue": "http://localhost:3000" } }
|
|
178
|
+
]
|
|
179
|
+
},
|
|
180
|
+
"scopeSpans": [{
|
|
181
|
+
"spans": [{
|
|
182
|
+
"traceId": "abc123",
|
|
183
|
+
"spanId": "def456",
|
|
184
|
+
"name": "test-span",
|
|
185
|
+
"kind": 2,
|
|
186
|
+
"startTimeUnixNano": "1737835200000000000",
|
|
187
|
+
"endTimeUnixNano": "1737835200150000000"
|
|
188
|
+
}]
|
|
189
|
+
}]
|
|
190
|
+
}]
|
|
191
|
+
}'
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Local Development
|
|
195
|
+
|
|
112
196
|
```bash
|
|
113
|
-
# Send a test trace
|
|
197
|
+
# Send a test trace to local instance
|
|
114
198
|
curl -X POST http://localhost:4318/v1/traces \
|
|
115
199
|
-H "Content-Type: application/json" \
|
|
116
200
|
-d '{
|
|
@@ -247,6 +331,11 @@ Issues and PRs welcome!
|
|
|
247
331
|
|
|
248
332
|
## See Also
|
|
249
333
|
|
|
250
|
-
|
|
334
|
+
### Documentation
|
|
335
|
+
- [docs/architecture/DESIGN.md](./docs/architecture/DESIGN.md) - Detailed system architecture
|
|
336
|
+
- [.principal-views/production-deployment.md](./.principal-views/production-deployment.md) - Production architecture decisions
|
|
337
|
+
- [docs/deployment/PRODUCTION.md](./docs/deployment/PRODUCTION.md) - Production operational guide
|
|
338
|
+
|
|
339
|
+
### External Resources
|
|
251
340
|
- [OpenTelemetry Collector](https://opentelemetry.io/docs/collector/)
|
|
252
341
|
- [OTLP Specification](https://opentelemetry.io/docs/specs/otlp/)
|
|
@@ -9,6 +9,7 @@ export declare class OTELCollectorServer {
|
|
|
9
9
|
private binaryManager;
|
|
10
10
|
private configGenerator;
|
|
11
11
|
private processManager;
|
|
12
|
+
private httpRouter;
|
|
12
13
|
private httpServer;
|
|
13
14
|
private traceOutput;
|
|
14
15
|
private portRouter;
|
|
@@ -35,11 +36,11 @@ export declare class OTELCollectorServer {
|
|
|
35
36
|
/**
|
|
36
37
|
* Register a MessagePort for a specific window (Electron mode only)
|
|
37
38
|
*/
|
|
38
|
-
registerPort(windowId: string,
|
|
39
|
+
registerPort(windowId: string, serviceName: string, port: MessagePort): void;
|
|
39
40
|
/**
|
|
40
41
|
* Unregister a MessagePort for a specific window (Electron mode only)
|
|
41
42
|
*/
|
|
42
|
-
unregisterPort(windowId: string,
|
|
43
|
+
unregisterPort(windowId: string, serviceName: string): void;
|
|
43
44
|
/**
|
|
44
45
|
* Unregister all MessagePorts for a specific window (Electron mode only)
|
|
45
46
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OTELCollectorServer.d.ts","sourceRoot":"","sources":["../src/OTELCollectorServer.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"OTELCollectorServer.d.ts","sourceRoot":"","sources":["../src/OTELCollectorServer.ts"],"names":[],"mappings":"AAAA;;GAEG;AAgBH,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAclD,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,CAAa;IAC/B,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;IAoD3D;;OAEG;IACG,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA2F5B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgC3B;;OAEG;IACH,OAAO,IAAI,OAAO;IAIlB;;OAEG;IACH,QAAQ,IAAI,WAAW;IAgBvB;;OAEG;IACH,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,IAAI;IAY5E;;OAEG;IACH,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI;IAY3D;;OAEG;IACH,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI;IAYxC;;OAEG;IACH,OAAO,CAAC,iBAAiB;CAqB1B"}
|
|
@@ -44,6 +44,7 @@ const BinaryManager_1 = require("./core/BinaryManager");
|
|
|
44
44
|
const ConfigGenerator_1 = require("./core/ConfigGenerator");
|
|
45
45
|
const CollectorProcessManager_1 = require("./core/CollectorProcessManager");
|
|
46
46
|
const OTLPForwardingServer_1 = require("./server/OTLPForwardingServer");
|
|
47
|
+
const HTTPRouter_1 = require("./router/HTTPRouter");
|
|
47
48
|
const ConsoleOutput_1 = require("./output/ConsoleOutput");
|
|
48
49
|
const FileOutput_1 = require("./output/FileOutput");
|
|
49
50
|
const MessagePortOutput_1 = require("./output/MessagePortOutput");
|
|
@@ -51,8 +52,9 @@ const PortRouter_1 = require("./router/PortRouter");
|
|
|
51
52
|
const logger_1 = require("./shared/logger");
|
|
52
53
|
const DEFAULT_CONFIG = {
|
|
53
54
|
mode: 'standalone',
|
|
54
|
-
otlpPort: 4318,
|
|
55
|
-
|
|
55
|
+
otlpPort: 4318, // Public-facing router port
|
|
56
|
+
collectorPort: 4320, // Internal Go collector port
|
|
57
|
+
wrapperPort: 4319, // Internal Node.js wrapper port
|
|
56
58
|
logLevel: 'info',
|
|
57
59
|
autoStart: true,
|
|
58
60
|
restartOnCrash: true,
|
|
@@ -73,7 +75,27 @@ class OTELCollectorServer {
|
|
|
73
75
|
// Initialize components
|
|
74
76
|
this.binaryManager = new BinaryManager_1.BinaryManager(this.config.collectorVersion, this.logger.createChild('BinaryManager'), this.config.binaryPath);
|
|
75
77
|
this.configGenerator = new ConfigGenerator_1.ConfigGenerator(this.logger.createChild('ConfigGenerator'));
|
|
76
|
-
|
|
78
|
+
// Build version registry config from environment variables
|
|
79
|
+
const versionRegistryConfig = process.env.VERSION_REGISTRY_URL && process.env.VERSION_REGISTRY_CUSTOMER_ID
|
|
80
|
+
? {
|
|
81
|
+
url: process.env.VERSION_REGISTRY_URL,
|
|
82
|
+
customerId: process.env.VERSION_REGISTRY_CUSTOMER_ID,
|
|
83
|
+
cacheTTL: process.env.VERSION_REGISTRY_CACHE_TTL
|
|
84
|
+
? parseInt(process.env.VERSION_REGISTRY_CACHE_TTL, 10)
|
|
85
|
+
: undefined,
|
|
86
|
+
}
|
|
87
|
+
: undefined;
|
|
88
|
+
this.httpServer = new OTLPForwardingServer_1.OTLPForwardingServer({
|
|
89
|
+
port: this.config.wrapperPort,
|
|
90
|
+
enableCORS: true,
|
|
91
|
+
versionRegistry: versionRegistryConfig,
|
|
92
|
+
}, this.traceOutput, this.logger.createChild('HTTPServer'));
|
|
93
|
+
this.httpRouter = new HTTPRouter_1.HTTPRouter({
|
|
94
|
+
port: this.config.otlpPort,
|
|
95
|
+
collectorPort: this.config.collectorPort,
|
|
96
|
+
wrapperPort: this.config.wrapperPort,
|
|
97
|
+
enableCORS: true,
|
|
98
|
+
}, this.logger.createChild('HTTPRouter'));
|
|
77
99
|
// Config file path
|
|
78
100
|
this.configFilePath = path.join(os.tmpdir(), `otel-collector-config-${Date.now()}.yaml`);
|
|
79
101
|
}
|
|
@@ -89,21 +111,29 @@ class OTELCollectorServer {
|
|
|
89
111
|
const binaryPath = await this.binaryManager.ensureBinary();
|
|
90
112
|
this.logger.info(`Binary found: ${binaryPath}`);
|
|
91
113
|
// 2. Generate config
|
|
92
|
-
this.logger.info('Step 2/
|
|
93
|
-
// Use different metrics port if
|
|
94
|
-
const metricsPort = this.config.
|
|
114
|
+
this.logger.info('Step 2/5: Generating collector config...');
|
|
115
|
+
// Use different metrics port if collector port is non-standard (i.e., dev mode)
|
|
116
|
+
const metricsPort = this.config.collectorPort !== 4320 ? this.config.collectorPort + 4570 : 8888;
|
|
95
117
|
await this.configGenerator.writeConfig({
|
|
96
|
-
|
|
118
|
+
collectorPort: this.config.collectorPort,
|
|
97
119
|
wrapperPort: this.config.wrapperPort,
|
|
98
120
|
metricsPort,
|
|
99
121
|
logLevel: this.config.logLevel,
|
|
122
|
+
// Security config
|
|
123
|
+
bindAddress: this.config.bindAddress,
|
|
124
|
+
requireAuth: this.config.requireAuth,
|
|
125
|
+
authToken: this.config.authToken,
|
|
126
|
+
allowedServices: this.config.allowedServices,
|
|
100
127
|
}, this.configFilePath);
|
|
101
128
|
this.logger.info(`Config written: ${this.configFilePath}`);
|
|
102
|
-
// 3. Start
|
|
103
|
-
this.logger.info('Step 3/
|
|
129
|
+
// 3. Start Node.js wrapper server (internal)
|
|
130
|
+
this.logger.info('Step 3/5: Starting Node.js wrapper server...');
|
|
104
131
|
await this.httpServer.start();
|
|
105
|
-
// 4. Start
|
|
106
|
-
this.logger.info('Step 4/
|
|
132
|
+
// 4. Start HTTP router (public-facing)
|
|
133
|
+
this.logger.info('Step 4/5: Starting HTTP router...');
|
|
134
|
+
await this.httpRouter.start();
|
|
135
|
+
// 5. Start collector process
|
|
136
|
+
this.logger.info('Step 5/5: Starting collector process...');
|
|
107
137
|
this.processManager = new CollectorProcessManager_1.CollectorProcessManager({
|
|
108
138
|
binaryPath,
|
|
109
139
|
configPath: this.configFilePath,
|
|
@@ -127,8 +157,14 @@ class OTELCollectorServer {
|
|
|
127
157
|
this.logger.info('OTEL Collector Server Started Successfully!');
|
|
128
158
|
this.logger.info('='.repeat(70));
|
|
129
159
|
this.logger.info(`Mode: ${this.config.mode}`);
|
|
130
|
-
this.logger.info(`
|
|
131
|
-
this.logger.info(`
|
|
160
|
+
this.logger.info(`Public Endpoint: http://localhost:${this.config.otlpPort}`);
|
|
161
|
+
this.logger.info(` └─ POST /v1/traces → Go Collector :${this.config.collectorPort}`);
|
|
162
|
+
this.logger.info(` └─ GET /traces* → Node.js Wrapper :${this.config.wrapperPort}`);
|
|
163
|
+
this.logger.info(`Bind Address (internal): ${this.config.bindAddress || '127.0.0.1'}`);
|
|
164
|
+
this.logger.info(`Authentication: ${this.config.requireAuth ? 'Enabled (Bearer Token)' : 'Disabled'}`);
|
|
165
|
+
if (this.config.allowedServices && this.config.allowedServices.length > 0) {
|
|
166
|
+
this.logger.info(`Service Allowlist: ${this.config.allowedServices.join(', ')}`);
|
|
167
|
+
}
|
|
132
168
|
if (this.config.mode === 'standalone') {
|
|
133
169
|
this.logger.info(`Output: ${this.config.output}${this.config.outputFile ? ` (${this.config.outputFile})` : ''}`);
|
|
134
170
|
}
|
|
@@ -151,6 +187,8 @@ class OTELCollectorServer {
|
|
|
151
187
|
await this.processManager.stop();
|
|
152
188
|
this.processManager = null;
|
|
153
189
|
}
|
|
190
|
+
// Stop HTTP router
|
|
191
|
+
await this.httpRouter.stop();
|
|
154
192
|
// Stop HTTP server
|
|
155
193
|
await this.httpServer.stop();
|
|
156
194
|
// Close file output if used
|
|
@@ -188,33 +226,33 @@ class OTELCollectorServer {
|
|
|
188
226
|
status: 'stopped',
|
|
189
227
|
},
|
|
190
228
|
uptime: this.startTime > 0 ? Date.now() - this.startTime : 0,
|
|
191
|
-
otlpPort: this.config.otlpPort,
|
|
192
|
-
wrapperPort: this.config.wrapperPort,
|
|
229
|
+
otlpPort: this.config.otlpPort, // Public router port
|
|
230
|
+
wrapperPort: this.config.wrapperPort, // Internal wrapper port
|
|
193
231
|
};
|
|
194
232
|
}
|
|
195
233
|
/**
|
|
196
234
|
* Register a MessagePort for a specific window (Electron mode only)
|
|
197
235
|
*/
|
|
198
|
-
registerPort(windowId,
|
|
236
|
+
registerPort(windowId, serviceName, port) {
|
|
199
237
|
if (this.config.mode !== 'electron') {
|
|
200
238
|
throw new Error('registerPort() is only available in Electron mode');
|
|
201
239
|
}
|
|
202
240
|
if (!this.portRouter) {
|
|
203
241
|
throw new Error('Port router not initialized');
|
|
204
242
|
}
|
|
205
|
-
this.portRouter.registerPort(windowId,
|
|
243
|
+
this.portRouter.registerPort(windowId, serviceName, port);
|
|
206
244
|
}
|
|
207
245
|
/**
|
|
208
246
|
* Unregister a MessagePort for a specific window (Electron mode only)
|
|
209
247
|
*/
|
|
210
|
-
unregisterPort(windowId,
|
|
248
|
+
unregisterPort(windowId, serviceName) {
|
|
211
249
|
if (this.config.mode !== 'electron') {
|
|
212
250
|
throw new Error('unregisterPort() is only available in Electron mode');
|
|
213
251
|
}
|
|
214
252
|
if (!this.portRouter) {
|
|
215
253
|
throw new Error('Port router not initialized');
|
|
216
254
|
}
|
|
217
|
-
this.portRouter.unregisterPort(windowId,
|
|
255
|
+
this.portRouter.unregisterPort(windowId, serviceName);
|
|
218
256
|
}
|
|
219
257
|
/**
|
|
220
258
|
* Unregister all MessagePorts for a specific window (Electron mode only)
|
|
@@ -1 +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;
|
|
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;AACrE,oDAAiD;AAEjD,0DAAuD;AACvD,oDAAiD;AACjD,kEAA+D;AAC/D,oDAAiD;AACjD,4CAAuD;AAIvD,MAAM,cAAc,GAAuC;IACzD,IAAI,EAAE,YAAY;IAClB,QAAQ,EAAE,IAAI,EAAE,4BAA4B;IAC5C,aAAa,EAAE,IAAI,EAAE,6BAA6B;IAClD,WAAW,EAAE,IAAI,EAAE,gCAAgC;IACnD,QAAQ,EAAE,MAAM;IAChB,SAAS,EAAE,IAAI;IACf,cAAc,EAAE,IAAI;IACpB,MAAM,EAAE,SAAS;IACjB,WAAW,EAAE,IAA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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;AAlSD,kDAkSC"}
|
|
@@ -5,12 +5,77 @@
|
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
const OTELCollectorServer_1 = require("../OTELCollectorServer");
|
|
8
|
-
// Parse
|
|
9
|
-
function
|
|
10
|
-
const args = process.argv.slice(2);
|
|
8
|
+
// Parse environment variables
|
|
9
|
+
function parseEnv() {
|
|
11
10
|
const config = {
|
|
12
11
|
mode: 'standalone',
|
|
13
12
|
};
|
|
13
|
+
// Parse environment variables
|
|
14
|
+
if (process.env.OTLP_PORT) {
|
|
15
|
+
config.otlpPort = parseInt(process.env.OTLP_PORT, 10);
|
|
16
|
+
}
|
|
17
|
+
if (process.env.COLLECTOR_PORT) {
|
|
18
|
+
config.collectorPort = parseInt(process.env.COLLECTOR_PORT, 10);
|
|
19
|
+
}
|
|
20
|
+
if (process.env.WRAPPER_PORT) {
|
|
21
|
+
config.wrapperPort = parseInt(process.env.WRAPPER_PORT, 10);
|
|
22
|
+
}
|
|
23
|
+
if (process.env.OUTPUT) {
|
|
24
|
+
const output = process.env.OUTPUT.toLowerCase();
|
|
25
|
+
if (output !== 'console' && output !== 'file') {
|
|
26
|
+
console.error(`Invalid OUTPUT env var: ${output}. Must be 'console' or 'file'`);
|
|
27
|
+
process.exit(1);
|
|
28
|
+
}
|
|
29
|
+
config.output = output;
|
|
30
|
+
}
|
|
31
|
+
if (process.env.OUTPUT_FILE) {
|
|
32
|
+
config.outputFile = process.env.OUTPUT_FILE;
|
|
33
|
+
config.output = 'file';
|
|
34
|
+
}
|
|
35
|
+
if (process.env.PRETTY_PRINT) {
|
|
36
|
+
config.prettyPrint = process.env.PRETTY_PRINT.toLowerCase() === 'true';
|
|
37
|
+
}
|
|
38
|
+
if (process.env.LOG_LEVEL) {
|
|
39
|
+
const level = process.env.LOG_LEVEL.toLowerCase();
|
|
40
|
+
if (!['debug', 'info', 'warn', 'error'].includes(level)) {
|
|
41
|
+
console.error(`Invalid LOG_LEVEL env var: ${level}`);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
config.logLevel = level;
|
|
45
|
+
}
|
|
46
|
+
if (process.env.COLLECTOR_VERSION) {
|
|
47
|
+
config.collectorVersion = process.env.COLLECTOR_VERSION;
|
|
48
|
+
}
|
|
49
|
+
if (process.env.BINARY_PATH) {
|
|
50
|
+
config.binaryPath = process.env.BINARY_PATH;
|
|
51
|
+
}
|
|
52
|
+
// Security options
|
|
53
|
+
if (process.env.BIND_ADDRESS) {
|
|
54
|
+
const bindAddress = process.env.BIND_ADDRESS;
|
|
55
|
+
if (bindAddress !== '0.0.0.0' && bindAddress !== '127.0.0.1') {
|
|
56
|
+
console.error(`Invalid BIND_ADDRESS env var: ${bindAddress}. Must be '0.0.0.0' or '127.0.0.1'`);
|
|
57
|
+
process.exit(1);
|
|
58
|
+
}
|
|
59
|
+
config.bindAddress = bindAddress;
|
|
60
|
+
}
|
|
61
|
+
if (process.env.REQUIRE_AUTH) {
|
|
62
|
+
config.requireAuth = process.env.REQUIRE_AUTH.toLowerCase() === 'true';
|
|
63
|
+
}
|
|
64
|
+
if (process.env.AUTH_TOKEN) {
|
|
65
|
+
config.authToken = process.env.AUTH_TOKEN;
|
|
66
|
+
}
|
|
67
|
+
if (process.env.ALLOWED_SERVICES) {
|
|
68
|
+
// Comma-separated list
|
|
69
|
+
config.allowedServices = process.env.ALLOWED_SERVICES.split(',')
|
|
70
|
+
.map((s) => s.trim())
|
|
71
|
+
.filter((s) => s.length > 0);
|
|
72
|
+
}
|
|
73
|
+
return config;
|
|
74
|
+
}
|
|
75
|
+
// Parse command line arguments (override environment variables)
|
|
76
|
+
function parseArgs() {
|
|
77
|
+
const args = process.argv.slice(2);
|
|
78
|
+
const config = {};
|
|
14
79
|
for (let i = 0; i < args.length; i++) {
|
|
15
80
|
const arg = args[i];
|
|
16
81
|
switch (arg) {
|
|
@@ -74,33 +139,61 @@ OpenTelemetry Collector Server - Standalone Mode
|
|
|
74
139
|
|
|
75
140
|
Usage: otel-collector-server [options]
|
|
76
141
|
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
142
|
+
Configuration:
|
|
143
|
+
The server can be configured via environment variables or command-line arguments.
|
|
144
|
+
Command-line arguments take precedence over environment variables.
|
|
145
|
+
|
|
146
|
+
Environment Variables:
|
|
147
|
+
OTLP_PORT Public-facing router port (default: 4318)
|
|
148
|
+
COLLECTOR_PORT Internal Go collector port (default: 4320)
|
|
149
|
+
WRAPPER_PORT Internal Node.js wrapper port (default: 4319)
|
|
150
|
+
OUTPUT Output type: console | file (default: console)
|
|
151
|
+
OUTPUT_FILE Base directory path for trace files (only used when OUTPUT=file)
|
|
152
|
+
Creates service-specific subdirectories: {OUTPUT_FILE}/{service-name}/traces.jsonl
|
|
153
|
+
PRETTY_PRINT Pretty print: true | false (default: true)
|
|
154
|
+
LOG_LEVEL Log level: debug | info | warn | error (default: info)
|
|
155
|
+
COLLECTOR_VERSION Collector version (e.g., v0.144.0)
|
|
156
|
+
BINARY_PATH Custom binary path (optional)
|
|
157
|
+
|
|
158
|
+
Security:
|
|
159
|
+
BIND_ADDRESS Bind address: 0.0.0.0 | 127.0.0.1 (default: 127.0.0.1)
|
|
160
|
+
REQUIRE_AUTH Enable authentication: true | false (default: false)
|
|
161
|
+
AUTH_TOKEN Bearer token for authentication (required if REQUIRE_AUTH=true)
|
|
162
|
+
ALLOWED_SERVICES Comma-separated list of allowed service names (optional)
|
|
163
|
+
|
|
164
|
+
Command-Line Options:
|
|
165
|
+
-p, --port <port> OTLP endpoint port (overrides OTLP_PORT)
|
|
166
|
+
--wrapper-port <port> Wrapper HTTP port (overrides WRAPPER_PORT)
|
|
167
|
+
-o, --output <type> Output type: console | file (overrides OUTPUT)
|
|
168
|
+
-f, --file <path> Output file path (overrides OUTPUT_FILE, sets output to file)
|
|
169
|
+
--pretty Pretty print console output (overrides PRETTY_PRINT)
|
|
170
|
+
--no-pretty Disable pretty printing (overrides PRETTY_PRINT)
|
|
171
|
+
-l, --log-level <level> Log level: debug | info | warn | error (overrides LOG_LEVEL)
|
|
172
|
+
--version <version> Collector version (overrides COLLECTOR_VERSION)
|
|
86
173
|
-h, --help Show this help message
|
|
87
174
|
|
|
88
175
|
Examples:
|
|
89
176
|
# Start with console output (pretty print)
|
|
90
177
|
otel-collector-server
|
|
91
178
|
|
|
92
|
-
# Start with file output
|
|
93
|
-
otel-collector-server --output file --file ./traces
|
|
179
|
+
# Start with file output (saves to ./traces/{service-name}/traces.jsonl)
|
|
180
|
+
otel-collector-server --output file --file ./traces
|
|
94
181
|
|
|
95
182
|
# Custom ports and debug logging
|
|
96
183
|
otel-collector-server --port 4318 --log-level debug
|
|
97
184
|
|
|
98
|
-
#
|
|
99
|
-
otel-collector-server
|
|
185
|
+
# Using environment variables
|
|
186
|
+
OTLP_PORT=4318 OUTPUT=file OUTPUT_FILE=./traces otel-collector-server
|
|
187
|
+
|
|
188
|
+
# Mix environment variables and CLI arguments (CLI takes precedence)
|
|
189
|
+
OTLP_PORT=5000 otel-collector-server --port 4318
|
|
100
190
|
`);
|
|
101
191
|
}
|
|
102
192
|
async function main() {
|
|
103
|
-
|
|
193
|
+
// Parse environment variables first, then override with command-line arguments
|
|
194
|
+
const envConfig = parseEnv();
|
|
195
|
+
const argsConfig = parseArgs();
|
|
196
|
+
const config = { ...envConfig, ...argsConfig };
|
|
104
197
|
console.log('Starting OpenTelemetry Collector Server (Standalone Mode)\n');
|
|
105
198
|
const server = new OTELCollectorServer_1.OTELCollectorServer(config);
|
|
106
199
|
// Handle shutdown signals
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"otel-collector-server.js","sourceRoot":"","sources":["../../src/bin/otel-collector-server.ts"],"names":[],"mappings":";;AAEA;;GAEG;;AAEH,gEAA6D;AAG7D,+BAA+B;
|
|
1
|
+
{"version":3,"file":"otel-collector-server.js","sourceRoot":"","sources":["../../src/bin/otel-collector-server.ts"],"names":[],"mappings":";;AAEA;;GAEG;;AAEH,gEAA6D;AAG7D,8BAA8B;AAC9B,SAAS,QAAQ;IACf,MAAM,MAAM,GAAuC;QACjD,IAAI,EAAE,YAAY;KACnB,CAAC;IAEF,8BAA8B;IAC9B,IAAI,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC;QAC1B,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACxD,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,CAAC;QAC/B,MAAM,CAAC,aAAa,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,EAAE,CAAC,CAAC;IAClE,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,CAAC;QAC7B,MAAM,CAAC,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;IAC9D,CAAC;IAED,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC;QACvB,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;QAChD,IAAI,MAAM,KAAK,SAAS,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;YAC9C,OAAO,CAAC,KAAK,CAAC,2BAA2B,MAAM,+BAA+B,CAAC,CAAC;YAChF,OAAO,CAAC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
5
5
|
export interface CollectorConfig {
|
|
6
|
-
|
|
6
|
+
collectorPort: number;
|
|
7
7
|
otlpGrpcPort?: number;
|
|
8
8
|
wrapperPort: number;
|
|
9
9
|
metricsPort?: number;
|
|
10
10
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
|
11
|
+
bindAddress?: '0.0.0.0' | '127.0.0.1';
|
|
12
|
+
requireAuth?: boolean;
|
|
13
|
+
authToken?: string;
|
|
14
|
+
allowedServices?: string[];
|
|
11
15
|
}
|
|
12
16
|
export declare class ConfigGenerator {
|
|
13
17
|
private logger;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConfigGenerator.d.ts","sourceRoot":"","sources":["../../src/core/ConfigGenerator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,EAAgB,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,eAAe;IAC9B,
|
|
1
|
+
{"version":3,"file":"ConfigGenerator.d.ts","sourceRoot":"","sources":["../../src/core/ConfigGenerator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,OAAO,EAAE,MAAM,EAAgB,MAAM,kBAAkB,CAAC;AAExD,MAAM,WAAW,eAAe;IAC9B,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;IAE/C,WAAW,CAAC,EAAE,SAAS,GAAG,WAAW,CAAC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;CAC5B;AAoED,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,CAAC,EAAE,MAAM;IAI3B;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM;IAqHzC;;OAEG;IACG,WAAW,CAAC,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAM5E"}
|
|
@@ -49,12 +49,22 @@ class ConfigGenerator {
|
|
|
49
49
|
*/
|
|
50
50
|
generate(config) {
|
|
51
51
|
this.logger.debug('Generating collector config:', config);
|
|
52
|
+
// Default to localhost for security (changed in v0.110.0+)
|
|
53
|
+
const bindAddress = config.bindAddress || '127.0.0.1';
|
|
54
|
+
// Build processors list
|
|
55
|
+
const processors = [];
|
|
56
|
+
// Add service allowlist filter if configured
|
|
57
|
+
if (config.allowedServices && config.allowedServices.length > 0) {
|
|
58
|
+
processors.push('filter/allowlist');
|
|
59
|
+
}
|
|
60
|
+
// Always add batch processor
|
|
61
|
+
processors.push('batch');
|
|
52
62
|
const collectorConfig = {
|
|
53
63
|
receivers: {
|
|
54
64
|
otlp: {
|
|
55
65
|
protocols: {
|
|
56
66
|
http: {
|
|
57
|
-
endpoint:
|
|
67
|
+
endpoint: `${bindAddress}:${config.collectorPort}`,
|
|
58
68
|
cors: {
|
|
59
69
|
allowed_origins: [
|
|
60
70
|
'http://localhost:*',
|
|
@@ -91,16 +101,46 @@ class ConfigGenerator {
|
|
|
91
101
|
pipelines: {
|
|
92
102
|
traces: {
|
|
93
103
|
receivers: ['otlp'],
|
|
94
|
-
processors
|
|
104
|
+
processors,
|
|
95
105
|
exporters: ['otlphttp'],
|
|
96
106
|
},
|
|
97
107
|
},
|
|
98
108
|
},
|
|
99
109
|
};
|
|
110
|
+
// Add authentication extension if required
|
|
111
|
+
if (config.requireAuth && config.authToken) {
|
|
112
|
+
this.logger.info('Enabling bearer token authentication');
|
|
113
|
+
collectorConfig.extensions = {
|
|
114
|
+
bearertokenauth: {
|
|
115
|
+
scheme: 'Bearer',
|
|
116
|
+
token: config.authToken,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
// Add auth to HTTP receiver
|
|
120
|
+
collectorConfig.receivers.otlp.protocols.http.auth = {
|
|
121
|
+
authenticator: 'bearertokenauth',
|
|
122
|
+
};
|
|
123
|
+
// Register extension in service
|
|
124
|
+
collectorConfig.service.extensions = ['bearertokenauth'];
|
|
125
|
+
}
|
|
126
|
+
// Add service allowlist filter if configured
|
|
127
|
+
if (config.allowedServices && config.allowedServices.length > 0) {
|
|
128
|
+
this.logger.info(`Enabling service allowlist filter: ${config.allowedServices.join(', ')}`);
|
|
129
|
+
// Build OTTL condition: drop if service.name is NOT in allowed list
|
|
130
|
+
// Logic: drop if (name != "svc1" AND name != "svc2" AND name != "svc3")
|
|
131
|
+
const conditions = config.allowedServices.map((svc) => `resource.attributes["service.name"] != "${svc}"`);
|
|
132
|
+
const filterCondition = conditions.join(' and ');
|
|
133
|
+
collectorConfig.processors['filter/allowlist'] = {
|
|
134
|
+
error_mode: 'ignore',
|
|
135
|
+
traces: {
|
|
136
|
+
span: [filterCondition],
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
100
140
|
// Add gRPC if configured
|
|
101
141
|
if (config.otlpGrpcPort) {
|
|
102
142
|
collectorConfig.receivers.otlp.protocols.grpc = {
|
|
103
|
-
endpoint:
|
|
143
|
+
endpoint: `${bindAddress}:${config.otlpGrpcPort}`,
|
|
104
144
|
};
|
|
105
145
|
}
|
|
106
146
|
const yamlStr = yaml.stringify(collectorConfig);
|