Documentation
¶
Overview ¶
cmd/example/main.go
Complete example application using the observability package with both metrics and tracing ¶
This example demonstrates:
- Automatic HTTP metrics and distributed tracing via unified middleware
- Manual DB operation instrumentation (metrics + tracing)
- Cache operation instrumentation (metrics + tracing)
- Custom span creation for business logic
- Error handling and span status management
- Graceful shutdown with proper cleanup
Environment Variables Required:
- APP_NAME: Service name (e.g., "example-api")
- APP_VERSION: Service version (e.g., "1.0.0")
- APP_ENV: Environment (development, staging, production)
- LOG_LEVEL: Logging level (debug, info, warn, error)
- OBSERVABILITY_METRICS_ENABLED: Enable metrics collection (true/false)
- OBSERVABILITY_TRACING_ENABLED: Enable distributed tracing (true/false)
- OBSERVABILITY_OTLP_ENDPOINT: OTLP collector endpoint (e.g., "localhost:4317")
Click to show internal directories.
Click to hide internal directories.