Documentation
¶
Overview ¶
Package main demonstrates a production-ready OpenTelemetry tracing setup with comprehensive configuration, error handling, and best practices for real-world applications.
This example shows: 1. Advanced configuration with environment-based setup 2. Proper error handling and recovery 3. Health checks and metrics endpoints 4. Graceful shutdown handling 5. Structured logging with trace correlation 6. Production-ready middleware stack 7. Database tracing with connection pooling 8. Circuit breaker pattern for resilience
Usage:
go run main.go curl http://localhost:8080/api/users curl http://localhost:8080/health curl http://localhost:8080/metrics
Environment Variables:
OTEL_SERVICE_NAME=production-service OTEL_SERVICE_VERSION=1.0.0 OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 OTEL_TRACES_SAMPLER=probabilistic OTEL_TRACES_SAMPLER_ARG=0.1
Click to show internal directories.
Click to hide internal directories.