feat(telemetry): initial stable release v0.9.0

Single-call OTel SDK bootstrap setting all three global providers (traces → Tempo, metrics → Mimir, logs → Loki) over OTLP gRPC.

What's included:
- New(ctx, Config): bootstraps TracerProvider, MeterProvider, and LoggerProvider with OTLP gRPC exporters; sets OTel globals
- W3C TraceContext + Baggage propagation set globally
- Resource tagging: service.name, service.version, deployment.environment merged with SDK defaults
- OTLPInsecure bool for development environments without TLS
- Sequential rollback on partial initialization failure — no dangling exporters on error
- Returns shutdown func(context.Context) error; caller defers in main or wires into launcher BeforeStop
- Tier 5 module: must be imported only by application main packages; zero micro-lib dependencies

Tested-via: todo-api POC integration
Reviewed-against: docs/adr/
This commit is contained in:
2026-03-18 14:13:29 -06:00
commit ed4e9ef161
14 changed files with 787 additions and 0 deletions

19
doc.go Normal file
View File

@@ -0,0 +1,19 @@
// Package telemetry bootstraps the OpenTelemetry SDK with OTLP gRPC exporters.
//
// It is a Tier-5 module — imported only by application main packages, never by
// framework libraries. Micro-libs use only the OTel API (zero-overhead no-op
// default). This module activates the real SDK with OTLP exporters so all
// micro-libs using the OTel global API auto-instrument without importing telemetry.
//
// Usage:
//
// shutdown, err := telemetry.New(ctx, telemetry.Config{
// ServiceName: "order-service",
// OTLPEndpoint: "alloy:4317",
// OTLPInsecure: true,
// })
// if err != nil {
// log.Fatalf("telemetry: %v", err)
// }
// defer shutdown(ctx)
package telemetry