Skip to main content

init

Function init 

Source
pub fn init(config: &Config) -> Result<TracingGuard>
Expand description

Initialise the global tracing subscriber.

Reads the log level from RUST_LOG if set; falls back to Config::level otherwise. Selects the output format from Config::format.

When Config::sentry contains a non-empty DSN, the Sentry SDK is also initialised and wired to the tracing subscriber via sentry-tracing. Sentry support is always compiled in — no feature flag is required.

Returns a TracingGuard that must be kept alive for the duration of the process. Dropping it flushes any buffered Sentry events.

Calling this function more than once in the same process is harmless — subsequent calls attempt try_init and silently ignore the “already initialised” error.

§Errors

Currently infallible. The Result return type is reserved for future validation of the Config fields at initialisation time.