|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +## Project Overview |
| 4 | + |
| 5 | +OpenTelemetry LGTM (Logs, Metrics, Traces) proxy that receives OTLP signals and forwards them to separate backends (Loki, Mimir, Tempo) with tenant ID injection. |
| 6 | + |
| 7 | +- **Language**: Go 1.26.0 |
| 8 | +- **Module**: `github.com/matt-gp/otel-lgtm-proxy` |
| 9 | + |
| 10 | +## Setup Commands |
| 11 | + |
| 12 | +- Install deps: `go mod download` |
| 13 | +- Generate mocks: `go generate ./...` |
| 14 | +- Build binary: `go build -o otel-lgtm-proxy ./cmd/main.go` |
| 15 | +- Run locally: `./otel-lgtm-proxy` |
| 16 | +- Build Docker: `docker build -t otel-lgtm-proxy .` |
| 17 | +- Run full stack: `docker compose up` |
| 18 | + |
| 19 | +## Testing Instructions |
| 20 | + |
| 21 | +- Run all tests: `go test -v ./...` |
| 22 | +- Run with coverage: `go test -v -race -coverprofile=coverage.out -covermode=atomic ./...` |
| 23 | +- View coverage: `go tool cover -html=coverage.out` |
| 24 | +- Run linter: `golangci-lint run` |
| 25 | +- Must have >90% test coverage before merging |
| 26 | + |
| 27 | +## Code Style |
| 28 | + |
| 29 | +- Use `golangci-lint` with project config (max complexity: 35) |
| 30 | +- Always check and handle errors explicitly |
| 31 | +- Use dependency injection via constructor functions named `New()` |
| 32 | +- Config via environment variables using `github.com/caarlos0/env/v6` |
| 33 | +- Package-level comments required: `// Package <name> <description>.` |
| 34 | +- Use table-driven tests for multiple test cases |
| 35 | +- Generate mocks with `//go:generate mockgen` directives |
| 36 | + |
| 37 | +## Docker Build |
| 38 | + |
| 39 | +- Multi-stage builds with Alpine base |
| 40 | +- Build flags: `-ldflags="-s -w" -trimpath` |
| 41 | +- Run as non-root user |
| 42 | +- `CGO_ENABLED=0` for static binaries |
| 43 | + |
| 44 | +## Project-Specific Patterns |
| 45 | + |
| 46 | +- Use `processor.Processor[T]` generic type for signal processing |
| 47 | +- Extract tenant ID from resource attributes using configured label(s) |
| 48 | +- Always propagate context for tracing and cancellation |
| 49 | +- Use protobuf getter methods (`Get*()`) instead of direct field access |
| 50 | + |
| 51 | +## CI/CD |
| 52 | + |
| 53 | +- Tests and lint must pass before merge |
| 54 | +- Docker build test validates container startup and health endpoint |
| 55 | +- Coverage reports uploaded to Codecov |
0 commit comments