Skip to main content

init_from_env

Function init_from_env 

Source
pub fn init_from_env() -> TelemetryGuard
Expand description

Initialize logging/tracing from environment — the simple-case wrapper around otel_layer_from_env for host processes that don’t already compose their own tracing_subscriber (no existing fmt layer, no Tracy/ other tracing consumer to combine with — see otel_layer_from_env if you do).

Always installs a tracing_subscriber fmt layer filtered by RUST_LOG/EnvFilter::from_default_env() — identical semantics to the env_logger::init() this replaces, so existing runbooks/ops tooling that set RUST_LOG keep working unchanged.

If MYKO_TRACING_ENDPOINT is set, additionally builds an OTLP/HTTP trace exporter (bridged into the same tracing spans via tracing-opentelemetry) and an OTLP/HTTP metrics exporter behind a periodic reader — export interval from MYKO_MEM_PROFILE_INTERVAL_SECS (seconds, default 60). If unset, telemetry stays local-only (console logging), matching the prior dev-loop behavior.