> For clean Markdown of any page, append .md to the page URL. For a task-oriented documentation index, fetch https://docs.nvidia.com/nemo/relay/llms.txt. Use the documentation version matching the installed NeMo Relay package: latest follows the latest stable release, vX.Y.Z identifies a retained release snapshot, and dev documents development changes. Preserve the selected version when following links; do not mix examples or API contracts from different versions. Fetch the relevant section's /llms.txt before individual pages instead of loading a complete version index. # Export ATOF Events > Configure raw ATOF event export to JSONL files and stream sinks. [Export](/configure-plugins/observability/atof) [Specification](/configure-plugins/observability/atof/spec) Use the `atof` section to write raw Agent Trajectory Observability Format (ATOF) `0.1` events to JSONL files, send them to raw-event collectors, or do both. When the `resource_metrics` component and polling are enabled, each poll emits one resource metric mark under every active explicit `Agent` scope. If no `Agent` scope is active, Relay emits one mark under the runtime root. The CLI pauses process-tree polling until it has a launched process to measure. An enabled ATOF subscriber writes each mark through the usual event path. Agent scope start and end events update the active-scope list; they do not trigger a sample. Refer to [Resource Metrics](/configure-plugins/resource-metrics) for the measurement and polling details. File sinks are useful for local debugging, offline inspection, and preserving the canonical event stream before another exporter translates it. Stream sinks send the same events to collectors in near real time. They can also transform dotted object keys before delivery. ## `plugins.toml` Example Add the following ATOF exporter configuration to `plugins.toml`: ```toml version = 1 [[components]] kind = "observability" enabled = true [components.config] version = 4 [components.config.atof] enabled = true [[components.config.atof.sinks]] type = "file" output_directory = "logs" filename = "events.jsonl" mode = "overwrite" [[components.config.atof.sinks]] type = "stream" name = "archive" url = "http://localhost:8080/events" transport = "http_post" timeout_millis = 3000 field_name_policy = "replace_dots" [components.config.atof.sinks.header_env] authorization = "NEMO_RELAY_ATOF_AUTH_HEADER" ``` Before you validate or activate this example, set `NEMO_RELAY_ATOF_AUTH_HEADER` to the complete authorization header value, such as `Bearer `. NeMo Relay rejects a missing or blank value. This configuration registers the plugin-managed ATOF exporter and writes one JSON object per lifecycle event to `logs/events.jsonl`. It also applies the `replace_dots` field-name policy and sends each raw event to the named `archive` stream sink. ## Fields The following table describes the top-level ATOF settings: | Field | Default | Notes | | --------- | ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `enabled` | `false` | Must be `true` to export events. | | `sinks` | `[]` | File and stream destinations. An enabled ATOF section requires at least one sink. Each event delivered to the ATOF subscriber is sent to every configured sink. | ## File Sinks Each file sink writes the raw event stream to one JSONL file. The following table describes each file sink: | Field | Default | Notes | | ------------------ | --------------------------------------- | ------------------------------------ | | `type` | Required | Sink variant. Must be `file`. | | `output_directory` | Current working directory | Directory containing the JSONL file. | | `filename` | Timestamped `nemo-relay-events-*.jsonl` | Output filename. | | `mode` | `append` | `append` or `overwrite`. | > **Note** > > Native event-producing APIs return before the ATOF subscriber necessarily > runs. After it receives an event, a file sink writes one complete JSONL record > and flushes the process writer. A subscriber flush waits for the file callback > to complete its write attempt for every event queued before the barrier. A > manual exporter reports any stored file errors during `force_flush()` or > `shutdown()`. Plugin teardown also reports stored file errors. > > Flushing the process writer does not call `fsync` or guarantee durability after > a machine crash. If the process terminates before the subscriber receives an > event, the corresponding record can still be lost. ## Stream Sinks Each stream sink receives the same canonical ATOF event that file sinks write. Before sending it, NeMo Relay applies the configured field-name policy and then uses the transport-specific encoding. WebSocket sends a JSON text message, while the HTTP transports send a JSONL record. Each stream runs independently, so a failed connection does not block file output or other streams. The following table describes each stream sink: | Field | Default | Notes | | ------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `type` | Required | Sink variant. Must be `stream`. | | `name` | Omitted | Optional stable name for cross-component references. Stream sink names must be unique, non-empty, and have no leading or trailing whitespace. | | `url` | Required | Stream URL. Use `http` or `https` for `http_post` and `ndjson`, and `ws` or `wss` for `websocket`. | | `transport` | `http_post` | `http_post`, `websocket`, or `ndjson`. | | `headers` | `{}` | String-to-string headers for requests or handshakes. | | `header_env` | `{}` | Maps each header name to an environment variable that contains the full header value. Each variable must be set and nonblank, and the same header cannot also appear in `headers`. | | `header_file` | `{}` | Maps each header name to a regular file that holds its full value. Files must exist at activation. HTTP POST reads it for each event. WebSocket reads it when it connects or reconnects. NDJSON reads it when its stream starts. | | `timeout_millis` | `3000` | Per-sink timeout for stream I/O and flush or close acknowledgement. Must be greater than `0`. | | `field_name_policy` | `preserve` | Field-name handling before Relay sends stream events. Accepted values are `preserve` and `replace_dots`. | Use `header_env` for secrets so the configuration stores the environment variable name instead of the secret value. Use `header_file` when another process updates a credential in place. Relay reads the UTF-8 file at the time listed above and removes trailing whitespace. If the file is missing, unreadable, blank, or invalid, only that delivery fails. Relay does not log the value. A header can use only one of `headers`, `header_env`, and `header_file`. Header names are case-insensitive. When you set any header source (`headers`, `header_env`, or `header_file`), remote ATOF HTTP destinations must use HTTPS and remote WebSocket destinations must use WSS. HTTP or WS is allowed only for localhost and loopback IP addresses, unless the host is listed in the not-recommended [`insecure_http_hosts`](/configure-plugins/observability/configuration#insecure-http-hosts) setting. A stream sink passed directly to `AtofExporter` through the Manual API can instead set `allow_insecure`. ATOF HTTP clients do not follow redirects when headers are set. Use the final collector URL. If a server sends a redirect, that delivery fails and Relay does not send headers to the new destination. `preserve` sends canonical ATOF field names unchanged. `replace_dots` replaces dots in JSON object keys with underscores recursively. If that creates a duplicate key, NeMo Relay keeps both values and appends `_2`, `_3`, and later suffixes in a deterministic order. Validation rejects any other `sinks[i].field_name_policy` value for a stream sink. The following transports are supported: * `http_post` sends each event as one JSONL record in an HTTP `POST` request with `Content-Type: application/x-ndjson`. Any `2xx` response is treated as success. * `websocket` opens one connection and sends each event as one JSON text message. * `ndjson` opens one long-lived HTTP upload and writes each event as one newline-delimited JSON record. For a file sink, the shared subscriber flush completes the synchronous file callback. For a stream sink, it only confirms that the ATOF callback queued the stream work. A manual exporter's `force_flush()` first waits for queued subscriber callbacks, then flushes file output or asks each stream worker to drain its queued events while keeping the exporter open. It waits for each stream worker up to that sink's `timeout_millis` value. If a worker does not acknowledge in time, NeMo Relay logs a warning and `force_flush()` can still return successfully; the worker can still have queued work. `shutdown()` follows the same delivery barrier, flushes file output, and asks each stream worker to drain and close within the configured timeout. It ignores events delivered after the exporter closes. A timeout is logged and does not by itself cause `shutdown()` to return an error. During graceful shutdown, `activation.close()` uses that same terminal stream-sink operation. Await it from Python and Node.js so queued sanitizers can finish on the running event loop. Teardown does not guarantee that a worker which timed out drained or closed. ## Runtime Diagnostics Stream sinks record a runtime diagnostic when delivery fails, drops, or times out. The following table lists diagnostic codes and when Relay records them: | Code | Recorded when | | ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | | `atof.stream_endpoint_disabled` | Sink cannot start. Relay drops later events. | | `atof.stream_connection_failed` | WebSocket connect, send, or drain fails. Relay keeps pending events and retries. | | `atof.stream_delivery_failed` | HTTP `POST` fails or returns non-`2xx`, header file cannot be read, or NDJSON upload with queued events fails. Count is queued events. Relay does not retry. | | `atof.stream_events_dropped` | WebSocket sink closes with undelivered events, NDJSON uploads end with events queued, or disabled or stopped sink receives an event. Relay does not deliver them. | | `atof.stream_flush_failed` | Sink does not confirm flush within `timeout_millis`, worker stopped, or NDJSON upload ended before the flush. | | `atof.stream_close_failed` | Sink does not confirm close within `timeout_millis`, worker stopped, or NDJSON upload does not finish in time. | Entries have a stable code, a running count, and distinct messages recorded for that code. Messages name transport and URL origin. Counts persist across flushes and shutdown. For direct-exporter diagnostic methods and examples, refer to [Runtime Diagnostics](/reference/api/observability#atof-runtime-diagnostics). Plugin-managed stream sinks also record diagnostics in the active plugin report's `runtime_diagnostics`, with `component` set to `observability` and `field` to `atof.sinks[i].url`. ## Expected Output Each file sink writes a scope, tool, LLM, middleware, or mark event delivered to the exporter as one ATOF JSON object per line. Stream sinks encode the delivered event as described in [Stream Sinks](#stream-sinks). For the normative event wire format, refer to the [ATOF Core Specification](/configure-plugins/observability/atof/spec). For Relay-specific event production semantics, refer to [Events](/about-nemo-relay/concepts/events). Coding-agent sessions emit a `session.start` mark with the logical `metadata.session_id`, a Relay-owned UUIDv7 `metadata.session_instance_id`, and optional session metadata such as `metadata.user_id`. Later trace exporters use these identities for correlation, but ATOF preserves them as raw event metadata. ATOF is the raw-event export path. It preserves the canonical event shape; it does not add semantic extraction, replay policy, scope-owner resolution, or exporter projection rules. Each owning agent scope starts fresh, and a `compaction` mark refreshes it. The first subsequent LLM start annotation retains complete history. Later starts retain system instructions, the latest user message, and every following assistant or tool message. With a request codec annotation, the emitted event input uses the same projection. If that event-only encoding fails, Relay retains the complete event input and annotation. The request used for provider execution remains unchanged. Refer to [Events](/about-nemo-relay/concepts/events) for the complete freshness contract. Set top-level `enable_full_payloads = true` to retain complete sanitized LLM request payloads on every start event. For a successful tool end event, ATOF stores `ToolExecutionResult.result` in `data`. When the result carries a present, non-null opaque annotation, ATOF stores it in `category_profile.tool_result_annotation`. The delivered event contains the post-sanitizer values. Register the plugin before instrumented work starts. Clear it during shutdown so every sink flushes pending events and stream connections close cleanly. Terminating the process before subscriber delivery or plugin teardown completes can leave the final records missing. ## Plugin Configuration Use plugin configuration when you want NeMo Relay to manage the ATOF exporter lifecycle. The following examples configure and activate the exporter through each supported language binding. `validate()` resolves the same configuration layers as `initialize()` without loading plugin code or acquiring the activation lease. Use Python/Rust `validate_exact()`, Node.js `validateExact()`, or Go `ValidateExact()` when only the supplied static configuration should be checked. For complete layering rules, refer to [Configure](/configure-plugins/plugin-configuration-files). #### Python ```python import asyncio from nemo_relay import plugin from nemo_relay.observability import ( AtofConfig, AtofFileSinkConfig, AtofStreamSinkConfig, ComponentSpec, ObservabilityConfig, ) config = plugin.PluginConfig( components=[ ComponentSpec( ObservabilityConfig( atof=AtofConfig( enabled=True, sinks=[ AtofFileSinkConfig( output_directory="logs", filename="events.jsonl", mode="overwrite", ), AtofStreamSinkConfig( url="http://localhost:8080/events", transport="http_post", ), ], ) ) ) ] ) report = plugin.validate(config)["config"] if any(diagnostic["level"] == "error" for diagnostic in report["diagnostics"]): raise RuntimeError(report["diagnostics"]) async def main() -> None: async with plugin.activate(config): # Run instrumented application work here. pass asyncio.run(main()) ``` #### Node.js ```js const plugin = require("nemo-relay-node/plugin"); const observability = require("nemo-relay-node/observability"); void (async () => { const activation = await plugin.initialize({ version: 1, components: [ observability.ComponentSpec({ version: 4, atof: observability.atofConfig({ enabled: true, sinks: [ { type: "file", output_directory: "logs", filename: "events.jsonl", mode: "overwrite", }, { type: "stream", url: "http://localhost:8080/events", transport: "http_post", }, ], }), }), ], }); try { // Run instrumented application work here. } finally { await activation.close(); } })().catch((error) => { console.error(error); process.exitCode = 1; }); ``` #### Rust ```rust use nemo_relay_observability::plugin::{ AtofFileSinkSectionConfig, AtofSectionConfig, AtofSinkSectionConfig, AtofStreamSinkSectionConfig, ComponentSpec, ObservabilityConfig, }; use nemo_relay::plugin::PluginConfig; use nemo_relay::plugin::{initialize, validate}; #[tokio::main] async fn main() -> Result<(), Box> { let component = ComponentSpec::new(ObservabilityConfig { atof: Some(AtofSectionConfig { enabled: true, sinks: vec![ AtofSinkSectionConfig::File(AtofFileSinkSectionConfig { output_directory: Some("logs".into()), filename: Some("events.jsonl".into()), mode: "overwrite".into(), }), AtofSinkSectionConfig::Stream(AtofStreamSinkSectionConfig { url: "http://localhost:8080/events".into(), transport: "http_post".into(), headers: Default::default(), header_env: Default::default(), timeout_millis: 3000, field_name_policy: "replace_dots".into(), name: Some("archive".into()), }), ], }), ..ObservabilityConfig::default() }); let config = PluginConfig { version: 1, components: vec![component.into()], policy: Default::default(), }; let report = validate(config.clone(), None)?; assert!(!report.config.has_errors()); let mut activation = initialize(config, None).await?; // Run instrumented application work here. activation.close()?; Ok(()) } ``` ## Manual API For direct API examples and lifecycle contracts, refer to [Manual API](/reference/api/observability#atof-manual-api). ## Common Configuration and Runtime Issues Common configuration and runtime issues include: * ATOF is enabled without at least one plugin-configured sink. * A file sink's `mode` is not `append` or `overwrite`. * A stream sink has an empty `url`, an unsupported `transport`, or a `timeout_millis` value of `0`. * The output directory is not writable at runtime. * `nemo-relay doctor` cannot deliver its synthetic ATOF mark probe to a configured stream sink. * A file sink is configured in a target that cannot access the native filesystem. * The process terminates before a subscriber or exporter barrier, so the file or stream destination is missing queued tail records. * A stream sink reports `atof.stream_*` runtime diagnostics after flush or close, so the collector rejected, dropped, or did not acknowledge deliveries. ## Docs - [Agent Trajectory Observability Format (ATOF) Core Specification](https://docs.nvidia.com/nemo/relay/v1.0.0/configure-plugins/observability/atof/spec.md): The normative ATOF 0.1 wire format for NeMo Relay lifecycle events.