v1.17.0
Distributed Tracing with OpenTelemetry
End-to-end distributed tracing across the entire request path, powered by OpenTelemetry. A single trace now spans all four transports and every architectural layer: controller -> usecase -> repo. It's exported over OTLP/gRPC to a collector (Jaeger in the docker stack).
What's new
- OTLP/gRPC exporter - a global
TracerProvider(pkg/tracing) with configurable endpoint, TLS, and sampling; spans batch-export to any OTLP-compatible backend. - Cross-transport context propagation - W3C
traceparent+baggage, so traces stay connected regardless of transport:- REST ->
otelfibermiddleware - gRPC ->
otelgrpcstats handler - AMQP RPC / NATS RPC -> trace context carried in message headers via custom carriers
- REST ->
- Instrumented business layers -> use cases and repositories wrapped in tracing decorators, giving full visibility from handler down to DB and external web API calls.
- Jaeger in the docker stack ->
make compose-up-allnow brings up Jaeger, reachable through the nginx reverse proxy. - No-op when disabled -> with
TRACING_ENABLED=false, a no-op tracer provider is installed; instrumentation runs unconditionally with zero overhead. - Internal routes excluded ->
/healthz,/metrics,/swaggerare not traced; only versioned API groups are instrumented.
Configuration
| Variable | Default | Description |
|---|---|---|
TRACING_ENABLED |
false |
Enable OpenTelemetry tracing |
TRACING_OTLP_ENDPOINT |
localhost:4317 |
OTLP/gRPC collector endpoint |
TRACING_OTLP_INSECURE |
true |
Disable TLS for the OTLP exporter |
TRACING_SAMPLE_RATE |
0.1 |
Parent-based sampling ratio |
⚠️ Sampling is parent-based - use1.0locally, but keep it low (0.1/0.01) in production.
Upgrade notes
- Tracing is off by default - no action required to keep current behavior. To enable, set
TRACING_ENABLED=trueand pointTRACING_OTLP_ENDPOINTat your collector. - Persistent repos were reorganized into per-domain packages to host the tracing decorators; the composition root was updated accordingly. No public API or transport contract changes.
PR's
- feat(OTEL): OTEL/OTLP integration by @soltanoff in #452
Full Changelog: v1.16.4...v1.17.0