feat(epic1): complete OpenTelemetry integration and add verification documentation

Story 1.6: OpenTelemetry Distributed Tracing
- Implemented tracer initialization with stdout (dev) and OTLP (prod) exporters
- Added HTTP request instrumentation via Gin middleware
- Integrated trace ID correlation in structured logs
- Added tracing configuration to config files
- Registered tracer provider in DI container

Documentation and Setup:
- Created Docker Compose setup for PostgreSQL database
- Added comprehensive Epic 1 summary with verification instructions
- Added Epic 0 summary with verification instructions
- Linked summaries in documentation index and epic READMEs
- Included detailed database testing instructions
- Added Docker Compose commands and troubleshooting guide

All Epic 1 stories (1.1-1.6) are now complete. Story 1.7 depends on Epic 2.
This commit is contained in:
2025-11-05 18:20:15 +01:00
parent 30320304f6
commit fde01bfc73
13 changed files with 873 additions and 54 deletions

View File

@@ -7,6 +7,8 @@ import (
"time"
"github.com/gin-gonic/gin"
"go.opentelemetry.io/contrib/instrumentation/github.com/gin-gonic/gin/otelgin"
"go.opentelemetry.io/otel/trace"
"git.dcentral.systems/toolz/goplt/internal/health"
"git.dcentral.systems/toolz/goplt/internal/metrics"
"git.dcentral.systems/toolz/goplt/pkg/config"
@@ -27,6 +29,7 @@ func NewServer(
healthRegistry *health.Registry,
metricsRegistry *metrics.Metrics,
errorBus errorbus.ErrorPublisher,
tracer trace.TracerProvider,
) (*Server, error) {
// Set Gin mode
env := cfg.GetString("environment")
@@ -37,6 +40,10 @@ func NewServer(
router := gin.New()
// Add middleware (order matters!)
// OpenTelemetry tracing should be first to capture all requests
if tracer != nil {
router.Use(otelgin.Middleware("platform", otelgin.WithTracerProvider(tracer)))
}
router.Use(RequestIDMiddleware())
router.Use(LoggingMiddleware(log))
router.Use(PanicRecoveryMiddleware(errorBus))