feat: Universal auto-instrumentation for all languages

## New Features

### Universal Instrumentation Container
- Created deploy/instrumentation/ with Dockerfile that downloads OTel agents for:
  - .NET (glibc and musl/Alpine versions)
  - Node.js (with auto-instrumentation package)
  - Python (bootstrap script + requirements)
  - Java (javaagent JAR)
  - Go (example code for compile-time instrumentation)
  - PHP (composer package + init script)

### Universal instrument.sh Script
- Auto-detects application language from running processes
- Generates docker-compose snippets for each language
- Supports: dotnet, nodejs, python, java, go, php
- Usage: ./instrument.sh <container> [language] [otlp_endpoint]

### Improved docker-compose.yml
- Added instrumentation init container with shared volume
- Added AGENT_KEY environment variable for proper auth
- Added ophion-agent service for host metrics collection
- Named containers for easier management
- Added ophion-network for service discovery

### Documentation
- Created docs/QUICK_START.md with:
  - Single-command installation
  - Instrumentation guide for all languages
  - Troubleshooting section
  - Authentication guide

### Auth Fixes
- Server now properly validates AGENT_KEY for agent authentication
- OTel Collector configured with AGENT_KEY for forwarding to server
- Fixed 401 errors when agents connect

## Files Changed
- docker-compose.yml: Complete stack with all services
- deploy/instrumentation/*: Universal OTel agent container
- deploy/docker/otel-collector-config.yaml: Fixed auth headers
- instrument.sh: Universal instrumentation script
- docs/QUICK_START.md: Complete quick start guide
- README.md: Updated with new features
- .env.example: Added AGENT_KEY

## Testing
- Go code compiles successfully
- Docker images build correctly
- All changes are backwards compatible
This commit is contained in:
2026-02-06 19:28:43 -03:00
parent 0cd8b96cd0
commit 6f9657a3a8
16 changed files with 1279 additions and 148 deletions

View File

@@ -1,6 +1,6 @@
# ═══════════════════════════════════════════════════════════
# 🐍 OPHION - OpenTelemetry Collector Configuration
# Receives traces/metrics/logs from instrumented applications
# Central collector for all instrumented applications
# ═══════════════════════════════════════════════════════════
receivers:
@@ -14,8 +14,10 @@ receivers:
cors:
allowed_origins:
- "*"
allowed_headers:
- "*"
# Prometheus receiver for metrics scraping (optional)
# Prometheus receiver for scraping metrics
prometheus:
config:
scrape_configs:
@@ -43,22 +45,24 @@ processors:
- key: collector.name
value: ophion-collector
action: upsert
- key: deployment.environment
from_attribute: OTEL_RESOURCE_ATTRIBUTES
action: upsert
# Attributes processor for enrichment
attributes:
actions:
- key: ophion.collected
value: true
action: upsert
# Transform processor for data enrichment
transform:
trace_statements:
- context: span
statements:
- set(attributes["ophion.collected"], true)
metric_statements:
- context: datapoint
statements:
- set(attributes["ophion.collected"], true)
exporters:
# Export to Ophion server via OTLP
otlphttp/ophion:
# Export traces to Ophion server via HTTP
otlphttp/traces:
endpoint: http://server:8080
headers:
Authorization: "Bearer ${env:AGENT_KEY}"
X-Ophion-Source: otel-collector
compression: gzip
retry_on_failure:
@@ -67,13 +71,29 @@ exporters:
max_interval: 30s
max_elapsed_time: 300s
# Debug exporter for troubleshooting (disable in production)
# Export metrics to Ophion server
otlphttp/metrics:
endpoint: http://server:8080
headers:
Authorization: "Bearer ${env:AGENT_KEY}"
X-Ophion-Source: otel-collector
compression: gzip
# Export logs to Ophion server
otlphttp/logs:
endpoint: http://server:8080
headers:
Authorization: "Bearer ${env:AGENT_KEY}"
X-Ophion-Source: otel-collector
compression: gzip
# Debug exporter for troubleshooting
debug:
verbosity: basic
sampling_initial: 5
sampling_thereafter: 200
# Prometheus exporter for collector metrics
# Prometheus exporter for collector's own metrics
prometheus:
endpoint: 0.0.0.0:8889
namespace: ophion_collector
@@ -99,20 +119,20 @@ service:
# Traces pipeline
traces:
receivers: [otlp]
processors: [memory_limiter, batch, resource, attributes]
exporters: [otlphttp/ophion, debug]
processors: [memory_limiter, batch, resource, transform]
exporters: [otlphttp/traces, debug]
# Metrics pipeline
# Metrics pipeline
metrics:
receivers: [otlp, prometheus]
processors: [memory_limiter, batch, resource]
exporters: [otlphttp/ophion, debug]
exporters: [otlphttp/metrics, debug]
# Logs pipeline
logs:
receivers: [otlp]
processors: [memory_limiter, batch, resource]
exporters: [otlphttp/ophion, debug]
exporters: [otlphttp/logs, debug]
telemetry:
logs: