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

@@ -4,6 +4,7 @@ import (
"context"
"git.dcentral.systems/toolz/goplt/pkg/logger"
"go.opentelemetry.io/otel/trace"
"go.uber.org/zap"
"go.uber.org/zap/zapcore"
)
@@ -87,6 +88,19 @@ func (zl *zapLogger) WithContext(ctx context.Context) logger.Logger {
fields = append(fields, zap.String("user_id", userID))
}
// Extract trace ID from OpenTelemetry context
span := trace.SpanFromContext(ctx)
if span.SpanContext().IsValid() {
traceID := span.SpanContext().TraceID().String()
spanID := span.SpanContext().SpanID().String()
if traceID != "" {
fields = append(fields, zap.String("trace_id", traceID))
}
if spanID != "" {
fields = append(fields, zap.String("span_id", spanID))
}
}
if len(fields) == 0 {
return zl
}