Function init_tracing

Source
pub fn init_tracing() -> Option<OtelGuard>
Expand description

Init tracing, returning an optional guard for the OTEL provider.

If the OTEL environment variables are not set, this function will initialize a basic tracing subscriber with a fmt layer. If the environment variables are set, it will initialize the OTEL provider with the specified configuration, as well as the fmt layer.

§Env Reads

  • TRACING_LOG_JSON - If set, will enable JSON logging.
  • As OtelConfig documentation for env var information.

§Panics

This function will panic if a global subscriber has already been set.