Skip to main content

Crate rusty_otel

Crate rusty_otel 

Source
Expand description

§rusty-otel

OpenTelemetry export layer for the rusty_agent_runtime engine.

rusty-agent-runtime already emits structured tracing spans from its executor (rusty.run → rusty.super_step → rusty.node). This crate wires a global tracing_subscriber that routes those spans to two sinks:

  • a human-readable fmt layer on stderr (always on), gated by an EnvFilter, and
  • an OTLP/HTTP span exporter (only when OTelConfig::otlp_endpoint is set), so the same spans show up in a collector / Jaeger / any OTLP-compatible backend.

§Quick start

// Local development: pretty logs only.
let _guard = rusty_otel::init_local("my-agent").unwrap();

// With a collector: logs + OTLP spans.
let _guard = rusty_otel::init(rusty_otel::OTelConfig {
    service_name: "my-agent".into(),
    otlp_endpoint: Some("http://localhost:4318/v1/traces".into()),
    log_filter: None, // RUST_LOG, defaulting to a sensible rusty filter
})
.unwrap();

Keep the returned OTelGuard alive for the duration of the process and call OTelGuard::shutdown before exit to flush any buffered spans.

Structs§

OTelConfig
Configuration for init.
OTelGuard
Handle returned by init/init_local. Shuts down the tracer provider (flushing any buffered spans) on OTelGuard::shutdown or on drop. Shutdown is idempotent.

Enums§

OTelError
Errors returned by init and init_local.

Constants§

DEFAULT_FILTER
Default log filter used when neither OTelConfig::log_filter nor the RUST_LOG environment variable provides one. rusty.super_step spans are emitted at DEBUG, so the rusty_agent_runtime=debug directive surfaces the full span taxonomy locally without drowning other crates in noise.

Functions§

init
Install the global tracing subscriber.
init_local
Install the global tracing subscriber with a local-only configuration: fmt layer + EnvFilter, no OTLP export. Equivalent to calling init with only a service name.

Type Aliases§

Result
Convenient result alias for this crate.