Skip to main content

init

Function init 

Source
pub fn init(
    log_format: &LogFormat,
    default_directive: &str,
) -> Result<Option<SdkTracerProvider>>
Expand description

Initialize application telemetry (Logging, Tracing, Metrics).

Configures:

  • tracing-subscriber::fmt for structured logging (JSON, compact, or pretty).
  • EnvFilter for dynamic log levels (RUST_LOG).
  • An optional OTLP trace-export layer (see [build_otlp_provider]).

The log format is controlled by UAR_SERVER__LOG_FORMAT or the server.log_format config key. Defaults to JSON for Kubernetes log aggregator compatibility.

default_directive is the filter used when RUST_LOG is unset; an explicit RUST_LOG always wins.

Returns the OTLP [SdkTracerProvider] when trace export is active, so the caller can shutdown() it on exit to flush buffered spans; None otherwise.