Skip to main content

init

Function init 

Source
pub fn init(cfg: MonocleConfig) -> TelemetryGuard
Expand description

Initialise tracing and (when enabled) OpenTelemetry export to Monocle.

Installs the global tracing subscriber. Always installs a stdout fmt layer; when cfg.api_key is present it additionally exports traces, metrics and logs over OTLP/HTTP. Returns a TelemetryGuard that must be kept alive for the process lifetime and flushed via TelemetryGuard::shutdown.

ยงPanics

Panics if the global subscriber is already set, or if an OTLP exporter fails to build (misconfigured endpoint/TLS). Call this once, early in main.