Skip to main content

Crate nanocodex_observability

Crate nanocodex_observability 

Source
Expand description

§Nanocodex Observability

Application-owned tracing and OpenTelemetry setup for Nanocodex.

The agent lifecycle emits complete structured spans and events through tracing. This crate installs one process-wide subscriber that can write those records locally, export them over OTLP/HTTP, or do both.

§Full-fidelity data boundary

Nanocodex tracing is a complete diagnostic copy of the data observed by an agent lifecycle. Ordered span events retain full prompts and instructions, model requests and responses, API-visible reasoning and summaries, opaque encrypted reasoning payloads, tool arguments and results, steering, and cancellation. Structural fields retain lineage and parentage, ordering, latency, token and prompt-cache measurements, routing state, and automatic gpt-5.6-sol USD estimates.

Tracing does not redact or truncate values based on their content. Treat local logs and OTLP backends as sensitive conversation and tool-execution stores, with access controls and retention policy at least as strict as the application’s primary data.

§Local tracing

Keep the returned guard alive for as long as spans may be emitted:

use nanocodex_observability::{LogFormat, ObservabilityBuilder};

let _observability = ObservabilityBuilder::new("checkout-agent", "1.4.0")
    .environment("production")
    .filter("warn,nanocodex=info,nanocodex_oai_api=info,nanocodex_tools=info")
    .format(LogFormat::Json)
    .install()?;

Local records go to stderr by default. Use LogOutput::File when the embedding application owns a durable trace path.

§OTLP export

Set a collector base endpoint to add OTLP/HTTP export alongside local output:

use nanocodex_observability::ObservabilityBuilder;

let mut observability = ObservabilityBuilder::new("checkout-agent", "1.4.0")
    .environment("staging")
    .otlp_endpoint("http://127.0.0.1:4318")
    .install()?;

observability.shutdown()?;

ObservabilityGuard::shutdown explicitly flushes pending spans. Dropping the guard also attempts shutdown, but cannot report a flush error.

Structs§

ObservabilityBuilder
Builder for local formatting and optional OTLP/HTTP trace export.
ObservabilityGuard
Keeps asynchronous formatting and OTLP providers alive and flushes them on drop.

Enums§

LogFormat
Human-readable or structured local tracing output.
LogOutput
Destination for the local formatting layer.
ObservabilityError
Failure to configure, install, or flush observability.