Go API Project Guide
Complete observability rollout for Go HTTP APIs
Use this guide for Go APIs where low latency and predictable resource usage are important.
Architecture Scope
- HTTP middleware and handlers.
- Service/domain packages.
- DB and outbound client boundaries.
Setup
Initialize the SDK and wrap your handler with the provided middleware:
The middleware emits one span (http.server METHOD) and one log per request with method, route, status, and duration. Stdlib log.* calls are also captured automatically.
Gin and Echo middleware are available under middleware/gin and middleware/echo.
Environment Variables
Validation Checklist
- Synthetic load emits stable telemetry
- Slow handlers appear clearly in spans
- Shutdown path flushes final queue
-
log.Println()calls appear as structured logs
Production Hardening
- Keep queues bounded to avoid memory pressure.
- Monitor ingest errors and retries.
- Validate instrumentation after router/middleware changes.
Troubleshooting
- Missing data under load: tune buffering/retry and inspect backpressure.
- Missing spans: ensure
mw.Middlewarewraps the outermost handler. - Inconsistent tags: enforce shared middleware decorators.