Overview
Implement the OpenTelemetry integration for the Go (Chi + sqlc) service as specified in src/go/adr/008-opentelemetry.md .
Parent issue: #14
Tasks
Add required Go modules (go.opentelemetry.io/otel, otel/sdk, otlptracegrpc, otlpmetricgrpc, otelhttp, contrib/instrumentation/runtime, semconv/v1.26.0)
Initialize SDK at startup — use no-op providers when OTEL_EXPORTER_OTLP_ENDPOINT is absent
Wrap Chi router with otelhttp.NewHandler for inbound HTTP traces and metrics
Wrap outbound HTTP clients with otelhttp.NewTransport
Add manual span wrapping around sqlc repository calls (no auto-instrumentation available)
Enable Go runtime metrics via go.opentelemetry.io/contrib/instrumentation/runtime (goroutines, heap, GC)
Inject trace/span IDs into log/slog structured log entries
Verify metrics baseline: http.server.request.duration, http.server.active_requests, go.goroutine.count, go.memory.used, go.gc.duration
Set resource attributes: service.name=lamp-control-api-go, service.version, deployment.environment
Ensure W3C TraceContext + Baggage propagation is enabled
Add/update tests to verify instrumentation wires up correctly
Instrumentation summary
Signal
Mechanism
Type
Traces – Inbound HTTP
otelhttp.NewHandler
Config only
Traces – Outbound HTTP
otelhttp.NewTransport
Config only
Traces – Database (sqlc)
Manual span wrapping via OTel Tracer API
Custom code
Metrics – HTTP server
otelhttp (auto-emitted)
Config only
Metrics – Go runtime
contrib/instrumentation/runtime
Config only
Logs
Manual trace.SpanFromContext + log/slog injection
Custom code
Acceptance criteria
SDK is a no-op when OTEL_EXPORTER_OTLP_ENDPOINT is not set
All three pillars (traces, metrics, logs) emit data when collector is configured
Existing tests continue to pass
Overview
Implement the OpenTelemetry integration for the Go (Chi + sqlc) service as specified in
src/go/adr/008-opentelemetry.md.Parent issue: #14
Tasks
go.opentelemetry.io/otel,otel/sdk,otlptracegrpc,otlpmetricgrpc,otelhttp,contrib/instrumentation/runtime,semconv/v1.26.0)OTEL_EXPORTER_OTLP_ENDPOINTis absentotelhttp.NewHandlerfor inbound HTTP traces and metricsotelhttp.NewTransportgo.opentelemetry.io/contrib/instrumentation/runtime(goroutines, heap, GC)log/slogstructured log entrieshttp.server.request.duration,http.server.active_requests,go.goroutine.count,go.memory.used,go.gc.durationservice.name=lamp-control-api-go,service.version,deployment.environmentInstrumentation summary
otelhttp.NewHandlerotelhttp.NewTransportotelhttp(auto-emitted)contrib/instrumentation/runtimetrace.SpanFromContext+log/sloginjectionAcceptance criteria
OTEL_EXPORTER_OTLP_ENDPOINTis not set