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,29 @@
# ═══════════════════════════════════════════════════════════
# 🐍 OPHION - Node.js Instrumented App Dockerfile
# Example showing how to add OpenTelemetry to any Node.js app
# ═══════════════════════════════════════════════════════════
FROM node:20-alpine
WORKDIR /app
# Copy package files
COPY package*.json ./
# Install dependencies + OpenTelemetry auto-instrumentation
RUN npm install && \
npm install @opentelemetry/auto-instrumentations-node \
@opentelemetry/api \
@opentelemetry/sdk-node \
@opentelemetry/exporter-trace-otlp-http \
@opentelemetry/exporter-metrics-otlp-http
# Copy application code
COPY . .
# Expose port
EXPOSE 3000
# Start with auto-instrumentation
# The NODE_OPTIONS env var in docker-compose.yml handles instrumentation
CMD ["node", "server.js"]

View File

@@ -0,0 +1,62 @@
# ═══════════════════════════════════════════════════════════
# 🐍 OPHION - Node.js Auto-Instrumentation Example
# Demonstrates automatic tracing for Node.js applications
# ═══════════════════════════════════════════════════════════
#
# Usage:
# docker-compose up -d
#
# This example shows how to instrument ANY Node.js app without
# code changes using @opentelemetry/auto-instrumentations-node
# ═══════════════════════════════════════════════════════════
version: '3.8'
services:
nodejs-app:
build:
context: .
dockerfile: Dockerfile
ports:
- "3001:3000"
environment:
# ════════════════════════════════════════════════════
# OpenTelemetry Auto-Instrumentation Configuration
# ════════════════════════════════════════════════════
# Service identification
- OTEL_SERVICE_NAME=nodejs-example-app
- OTEL_SERVICE_VERSION=1.0.0
# OTLP Exporter configuration (pointing to Ophion collector)
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
- OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
- OTEL_TRACES_EXPORTER=otlp
- OTEL_METRICS_EXPORTER=otlp
- OTEL_LOGS_EXPORTER=otlp
# Resource attributes
- OTEL_RESOURCE_ATTRIBUTES=deployment.environment=development,service.namespace=ophion-examples
# Sampling (1.0 = 100% of traces)
- OTEL_TRACES_SAMPLER=parentbased_traceidratio
- OTEL_TRACES_SAMPLER_ARG=1.0
# Propagation format
- OTEL_PROPAGATORS=tracecontext,baggage,b3multi
# Enable auto-instrumentation via Node.js loader
- NODE_OPTIONS=--require @opentelemetry/auto-instrumentations-node/register
networks:
- ophion
restart: unless-stopped
healthcheck:
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/health"]
interval: 10s
timeout: 5s
retries: 3
networks:
ophion:
external: true

View File

@@ -0,0 +1,17 @@
{
"name": "nodejs-instrumented-example",
"version": "1.0.0",
"description": "Example Node.js app with OpenTelemetry auto-instrumentation for Ophion",
"main": "server.js",
"scripts": {
"start": "node server.js",
"start:instrumented": "node --require @opentelemetry/auto-instrumentations-node/register server.js"
},
"dependencies": {
"express": "^4.18.2"
},
"devDependencies": {},
"keywords": ["ophion", "opentelemetry", "tracing", "observability"],
"author": "Ophion Team",
"license": "MIT"
}

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'}`);
});