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

@@ -0,0 +1,74 @@
# ═══════════════════════════════════════════════════════════
# 🔧 OPHION Universal Instrumentation Container
# Downloads and provides OpenTelemetry agents for all languages
# ═══════════════════════════════════════════════════════════
FROM alpine:3.19
LABEL org.opencontainers.image.title="OPHION Instrumentation"
LABEL org.opencontainers.image.description="OpenTelemetry agents for .NET, Node.js, Python, Java, Go, PHP"
# Install tools
RUN apk add --no-cache curl unzip bash jq
# Create directory structure
RUN mkdir -p /otel/{dotnet,dotnet-musl,nodejs,python,java,go,php}
WORKDIR /otel
# ═══════════════════════════════════════════════════════════
# .NET Auto-Instrumentation (glibc)
# ═══════════════════════════════════════════════════════════
ENV OTEL_DOTNET_VERSION=1.6.0
RUN curl -L --retry 3 --retry-delay 5 --max-time 120 \
"https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/download/v${OTEL_DOTNET_VERSION}/opentelemetry-dotnet-instrumentation-linux-glibc-x64.zip" \
-o /tmp/dotnet.zip && \
unzip -q /tmp/dotnet.zip -d /otel/dotnet && \
rm /tmp/dotnet.zip && \
chmod +x /otel/dotnet/*.sh 2>/dev/null || true
# .NET Auto-Instrumentation (musl/Alpine)
RUN curl -L --retry 3 --retry-delay 5 --max-time 120 \
"https://github.com/open-telemetry/opentelemetry-dotnet-instrumentation/releases/download/v${OTEL_DOTNET_VERSION}/opentelemetry-dotnet-instrumentation-linux-musl-x64.zip" \
-o /tmp/dotnet-musl.zip && \
unzip -q /tmp/dotnet-musl.zip -d /otel/dotnet-musl && \
rm /tmp/dotnet-musl.zip && \
chmod +x /otel/dotnet-musl/*.sh 2>/dev/null || true
# ═══════════════════════════════════════════════════════════
# Java Auto-Instrumentation
# Uses GitHub API to get proper redirect
# ═══════════════════════════════════════════════════════════
ENV OTEL_JAVA_VERSION=2.1.0
RUN JAVA_URL=$(curl -sL "https://api.github.com/repos/open-telemetry/opentelemetry-java-instrumentation/releases/tags/v${OTEL_JAVA_VERSION}" | \
jq -r '.assets[] | select(.name=="opentelemetry-javaagent.jar") | .browser_download_url') && \
if [ -n "$JAVA_URL" ] && [ "$JAVA_URL" != "null" ]; then \
curl -L --retry 3 --max-time 180 "$JAVA_URL" -o /otel/java/opentelemetry-javaagent.jar; \
else \
echo "Downloading Java agent directly..." && \
curl -L --retry 3 --max-time 180 \
"https://github.com/open-telemetry/opentelemetry-java-instrumentation/releases/download/v${OTEL_JAVA_VERSION}/opentelemetry-javaagent.jar" \
-o /otel/java/opentelemetry-javaagent.jar; \
fi && \
ls -la /otel/java/
# ═══════════════════════════════════════════════════════════
# Copy pre-created files for other languages
# ═══════════════════════════════════════════════════════════
COPY files/ /otel/
# Set permissions
RUN chmod -R 755 /otel && \
chmod +x /otel/python/bootstrap.sh 2>/dev/null || true
# Verify downloads
RUN echo "=== OPHION Instrumentation Contents ===" && \
ls -la /otel/ && \
echo "=== Java agent size ===" && \
ls -lh /otel/java/opentelemetry-javaagent.jar 2>/dev/null || echo "Java agent not present" && \
echo "=== .NET ===" && ls /otel/dotnet/ | head -5
# Volume for sharing with other containers
VOLUME ["/otel"]
CMD ["echo", "OpenTelemetry agents ready in /otel"]