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

165
README.md
View File

@@ -3,7 +3,8 @@
**Open Source Observability Platform — AI-Powered Monitoring**
[![License: AGPL-3.0](https://img.shields.io/badge/License-AGPL%203.0-blue.svg)](LICENSE)
[![Website](https://img.shields.io/badge/Website-ophion.com.br-purple)](https://ophion.com.br)
[![Go](https://img.shields.io/badge/Go-1.22-00ADD8.svg)](https://golang.org/)
[![Docker](https://img.shields.io/badge/Docker-Compose-2496ED.svg)](https://docs.docker.com/compose/)
---
@@ -21,22 +22,52 @@ OPHION é uma plataforma de observabilidade que combina **métricas, logs e trac
| **Correlação de Alertas com IA** | ✅ | 💰 | ❌ |
| **Previsões de Capacidade** | ✅ | 💰 | ❌ |
| Open Source | ✅ | ❌ | ✅ |
| **Auto-instrumentação Universal** | ✅ | 💰 | ❌ |
---
## 🚀 Instalação Rápida
## 🚀 Quick Start (1 Comando)
```bash
curl -fsSL https://get.ophion.com.br | bash
git clone https://github.com/bigtux/ophion.git && cd ophion && docker compose up -d
```
O instalador interativo irá:
- ✅ Verificar requisitos (Docker, Docker Compose)
- ✅ Coletar informações da sua empresa
- ✅ Gerar credenciais seguras
- ✅ Iniciar a plataforma
Aguarde ~2 minutos e acesse:
- **Dashboard:** http://localhost:3000
- **API:** http://localhost:8080
- **OTLP (traces):** localhost:4317 (gRPC) / localhost:4318 (HTTP)
**Pronto em menos de 5 minutos!**
📖 [Guia Completo de Quick Start](docs/QUICK_START.md)
---
## 🔧 Instrumentar Sua Aplicação
### Script Universal
```bash
# Auto-detecta a linguagem
./instrument.sh my-container
# Ou especifique
./instrument.sh my-container nodejs
./instrument.sh my-container python
./instrument.sh my-container java
./instrument.sh my-container dotnet
```
### Linguagens Suportadas
| Linguagem | Método | Complexidade |
|-----------|--------|--------------|
| **.NET** | Auto-instrumentation | 🟢 Zero code |
| **Node.js** | Auto-instrumentation | 🟢 Zero code |
| **Python** | Auto-instrumentation | 🟢 Zero code |
| **Java** | Java Agent | 🟢 Zero code |
| **Go** | SDK (compile-time) | 🟡 Pequenas mudanças |
| **PHP** | SDK | 🟡 Pequenas mudanças |
📖 [Guia de Instrumentação](docs/QUICK_START.md#-2-instrument-your-application)
---
@@ -47,66 +78,110 @@ O instalador interativo irá:
| CPU | 2 cores | 4+ cores |
| RAM | 4 GB | 8+ GB |
| Disco | 20 GB SSD | 100+ GB SSD |
| OS | Ubuntu 20.04+ | Ubuntu 22.04 LTS |
| Docker | 20.10+ | Latest |
| Docker Compose | v2+ | Latest |
---
## 🔧 Instalação Manual
## 📦 Arquitetura
```bash
# Clonar
git clone https://git.ophion.com.br/bigtux/ophion.git
cd ophion
# Configurar
cp .env.example .env
nano .env
# Iniciar
docker compose -f deploy/docker/docker-compose.yml up -d
```
┌─────────────────────────────────────────────────────────────────┐
│ YOUR APPLICATIONS │
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
│ │ Node.js │ │ Python │ │ Java │ │ .NET │ │ Go │ │
│ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ └────┬────┘ │
│ │ │ │ │ │ │
│ └───────────┴───────────┼───────────┴───────────┘ │
│ │ OTLP (4317/4318) │
└───────────────────────────────┼─────────────────────────────────┘
┌───────────────────────────────┼─────────────────────────────────┐
│ OPHION STACK ▼ │
│ ┌─────────────────────────────────────────────────┐ │
│ │ OpenTelemetry Collector │ │
│ │ (process, batch, export) │ │
│ └─────────────────────────┬───────────────────────┘ │
│ │ │
│ ┌────────────────┐ ▼ ┌────────────────┐ │
│ │ Dashboard │◄──► Server ◄──►│ PostgreSQL │ │
│ │ (Next.js) │ (Go API) │ ClickHouse │ │
│ └────────────────┘ │ Redis │ │
│ └────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
```
---
## 📦 Estrutura
## 🔐 Autenticação
### Para Aplicações (OTLP)
Envie traces para o OpenTelemetry Collector (porta 4317/4318) - sem auth necessário.
### Para API
Use `AGENT_KEY` para agents ou JWT para dashboard:
```bash
# .env
AGENT_KEY=my-secret-key
```
---
## 📦 Estrutura do Projeto
```
ophion/
├── install.sh # Instalador interativo
├── .env.example # Exemplo de configuração
├── docker-compose.yml # Stack completa
├── instrument.sh # Script de instrumentação
├── cmd/
│ ├── server/ # API Server (Go)
│ └── agent/ # Agent de coleta
├── dashboard/ # Frontend (Next.js)
├── deploy/docker/ # Docker configs
├── internal/ # Código interno
└── docs/ # Documentação
│ ├── server/ # API Server (Go)
│ └── agent/ # Agent de coleta
├── dashboard/ # Frontend (Next.js)
├── deploy/
│ ├── docker/ # Docker configs
│ └── instrumentation/ # Container com agents OTel
├── internal/ # Código interno Go
└── docs/
├── QUICK_START.md # ⭐ Comece aqui
├── INSTALL.md
└── SECURITY.md
```
---
## 🔐 Segurança
- **JWT + API Keys** (SHA256)
- **Bcrypt** para senhas
- **Rate Limiting**
- **RBAC** por roles
📖 [Guia de Segurança](docs/SECURITY.md)
---
## 📖 Documentação
- [Instalação](docs/INSTALL.md)
- ⭐ [Quick Start](docs/QUICK_START.md) - Comece em 5 minutos
- [Instalação Avançada](docs/INSTALL.md)
- [Segurança](docs/SECURITY.md)
- [Manual PDF](docs/OPHION_Manual_Instalacao.pdf)
- [Manual Completo](docs/MANUAL_COMPLETO.md)
---
## 🛠️ Desenvolvimento
```bash
# Clonar
git clone https://github.com/bigtux/ophion.git
cd ophion
# Compilar Go
go build ./...
# Rodar localmente
docker compose up -d postgres redis
go run ./cmd/server
# Testes
go test ./...
```
---
## 🆘 Suporte
- **Website:** [ophion.com.br](https://ophion.com.br)
- **Issues:** https://github.com/bigtux/ophion/issues
- **Email:** suporte@ophion.com.br
---