fix: add agent key auth for ingest endpoints

This commit is contained in:
2026-02-06 19:13:30 -03:00
parent 615a8b5404
commit 6038e82b22
18 changed files with 1244 additions and 5 deletions

View File

@@ -0,0 +1,67 @@
/**
* ═══════════════════════════════════════════════════════════
* 🐍 OPHION - Example Node.js Application
* This app is automatically instrumented by OpenTelemetry
* No code changes needed - just env vars!
* ═══════════════════════════════════════════════════════════
*/
const http = require('http');
const PORT = process.env.PORT || 3000;
// Simple HTTP server
const server = http.createServer((req, res) => {
const { url, method } = req;
console.log(`[${new Date().toISOString()}] ${method} ${url}`);
// Route handling
if (url === '/health') {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ status: 'healthy', service: 'nodejs-example' }));
return;
}
if (url === '/') {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({
message: 'Hello from Node.js!',
instrumented: true,
otelEndpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'not set'
}));
return;
}
if (url === '/api/users') {
// Simulate some work
setTimeout(() => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify([
{ id: 1, name: 'Alice' },
{ id: 2, name: 'Bob' },
{ id: 3, name: 'Charlie' }
]));
}, Math.random() * 100);
return;
}
if (url === '/api/slow') {
// Simulate slow operation (good for testing traces)
setTimeout(() => {
res.writeHead(200, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ message: 'Slow response', delay: '500ms' }));
}, 500);
return;
}
// 404
res.writeHead(404, { 'Content-Type': 'application/json' });
res.end(JSON.stringify({ error: 'Not Found' }));
});
server.listen(PORT, () => {
console.log(`🚀 Node.js server running on port ${PORT}`);
console.log(`📊 OTEL Endpoint: ${process.env.OTEL_EXPORTER_OTLP_ENDPOINT || 'not configured'}`);
console.log(`🏷️ Service Name: ${process.env.OTEL_SERVICE_NAME || 'unknown'}`);
});