pub fn init_tracing()Expand description
Initialise tracing with env-filter support. Call once at binary startup.
§Panics
This function does not panic.
§Log format
If RUST_LOG_FORMAT=json is set the subscriber emits newline-delimited
JSON suitable for log aggregation pipelines. Otherwise the human-readable
fmt pretty format is used for local development.
§OpenTelemetry OTLP export
If the environment variable OTEL_EXPORTER_OTLP_ENDPOINT (or the legacy
JAEGER_ENDPOINT) is set to a valid OTLP collector URL (e.g.
http://localhost:4318), spans are exported via OTLP HTTP to that endpoint
using a batch exporter on the Tokio runtime.
If neither variable is set (the common case in local development), the OTel layer is silently omitted — no error is printed and the binary starts normally. All other tracing output (stdout / log files) is unaffected.
A startup info! log is emitted either way so operators can confirm the
observability configuration at a glance:
"OpenTelemetry OTLP export enabled, sending to <endpoint>""OpenTelemetry OTLP disabled (set OTEL_EXPORTER_OTLP_ENDPOINT to enable)"
§Calling requirement
This function must be called after the Tokio runtime has started because
the OTLP batch exporter uses rt-tokio internally.