> ## Documentation Index
> Fetch the complete documentation index at: https://docs-omnicoreagent.omnirexfloralabs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Telemetry and exporters

> What every run records, where it is kept and for how long, the live event stream, usage metrics, and exporting traces to OTLP, LangSmith, Opik or a JSONL file

# Telemetry and exporters

Every run records a trace: a span for each piece of work and an event for
each thing that happened, kept on local disk with no service to run. By the
end of this page you will have followed a run live, event by event, sent its
trace to an OpenTelemetry collector and a JSONL file, and know what is
recorded, where, and for how long.

To read a run back step by step, see [Read a run](https://docs-omnicoreagent.omnirexfloralabs.com/docs/how-to-guides/read-a-run.md).

> [!NOTE]
>
> Every output on this page is what the code printed when it was run with
> `gpt-5.4-mini`. The model's wording, token counts, times and IDs will differ
> on your run.

## Watch a run, then send it on

The collector here is a small stand-in for an OpenTelemetry collector: it
accepts OTLP/HTTP on port 4318 and prints what arrives. It needs the `otel`
extra (`pip install "omnicoreagent[otel]"`).

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
# collector.py: prints every trace sent to it.
from http.server import BaseHTTPRequestHandler, HTTPServer
from opentelemetry.proto.collector.trace.v1.trace_service_pb2 import ExportTraceServiceRequest

class Receiver(BaseHTTPRequestHandler):
    def do_POST(self):
        body = self.rfile.read(int(self.headers["content-length"]))
        request = ExportTraceServiceRequest.FromString(body)
        for resource in request.resource_spans:
            service = {a.key: a.value.string_value for a in resource.resource.attributes}["service.name"]
            spans = [span for scope in resource.scope_spans for span in scope.spans]
            print(f"{self.path}: {len(spans)} spans from {service}:",
                  sorted({span.name for span in spans}), flush=True)
        self.send_response(200)
        self.end_headers()

    def log_message(self, *args):
        pass

HTTPServer(("127.0.0.1", 4318), Receiver).serve_forever()
```

The agent exports every trace to it, and to a JSONL file, when the trace
ends. A second task follows the run live from a cursor taken before it
started:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import asyncio
from omnicoreagent import OmniCoreAgent, ToolRegistry

tools = ToolRegistry()

@tools.register_tool("get_weather")
def get_weather(city: str) -> dict:
    """Get the current weather for a city."""
    return {"city": city, "temperature_c": 25}

agent = OmniCoreAgent(
    name="weather",
    system_instruction="Use get_weather. Answer in plain text, in one sentence.",
    model_config={"provider": "openai", "model": "gpt-5.4-mini"},
    local_tools=tools,
    telemetry_exporters=[
        {"destination": "otlp", "endpoint": "http://localhost:4318", "service_name": "weather-agent"},
        {"destination": "jsonl", "path": "exports/traces.jsonl"},
    ],
)

async def follow(cursor):
    async for event in agent.stream_telemetry_after(cursor=cursor, run_id="run-weather-1"):
        print("live:", event.event_type)
        if event.event_type == "final_answer":
            return

async def main():
    cursor = await agent.get_telemetry_stream_cursor()
    watcher = asyncio.create_task(follow(cursor))
    result = await agent.run("What is the weather in Nairobi?", session_id="demo", run_id="run-weather-1")
    await watcher
    print(result["response"])
    print("metric:", result["metric"].request_tokens, "request tokens,", result["metric"].requests, "requests")

    trace = await agent.get_trace(result["trace_id"])
    print("trace:", trace["status"], len(trace["spans"]), "spans,", len(trace["events"]), "events,",
          trace["metadata"]["telemetry_storage"])
    latest = await agent.get_latest_trace("demo")
    print("latest in session is this one:", latest["trace_id"] == result["trace_id"])
    print(await agent.get_metrics())
    await agent.cleanup()

asyncio.run(main())
```

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
live: user_message
live: guardrail_check
live: memory_read
live: run_configuration
live: runtime_message
live: memory_write
live: agent_step
live: context_assembly
live: context_message
live: context_message
live: context_tools
live: model_call
live: model_response
live: memory_write
live: tool_batch_start
live: tool_requested
live: tool_resolved
live: policy_request_created
live: policy_decision_allow
live: tool_call
live: tool_result
live: tool_observation
live: memory_write
live: observation_pipeline_end
live: tool_batch_end
live: agent_step
live: context_assembly
live: context_message
live: context_message
live: model_call
live: model_response
live: memory_write
live: final_answer
The weather in Nairobi is 25°C.
metric: 3016 request tokens, 2 requests
trace: completed 14 spans, 33 events, jsonl
latest in session is this one: True
{'total_requests': 2, 'total_request_tokens': 3016, 'total_response_tokens': 32, 'total_tokens': 3048, 'total_time': 7.65733917200123, 'average_time': 3.828669586000615}
```

And the collector printed:

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
/v1/traces: 14 spans from weather-agent: ['agent.run', 'agent.step', 'context.assembly', 'get_weather', 'memory.read', 'memory.write', 'model.call', 'tool.batch']
```

`exports/traces.jsonl` has one line: the whole trace, as JSON.

What happened:

* The watcher saw every event as it was recorded: the request, the run's
  header (`run_configuration`), each step's context, model call, the policy's
  decision on the tool call (governance is on by default), the tool call, and
  the answer. It passed `run_id=` to see only this run.
* `result["metric"]` counted two model requests: this run's two model calls.
* The trace was stored locally (`jsonl`, in `./workspace/telemetry/`) and
  exported when it ended: 14 spans to the collector, the same trace to the
  file.

## What a trace records

`telemetry_config` decides what goes into a trace. The facts are always
kept: IDs, the links between records, tokens, cost, latency, outcomes, policy
decisions and the run's header are event metadata, recorded under every
setting. The **payloads** (what the model was sent and answered, tool
arguments and results) follow the capture policy:

| `capture` | Records |
| - | - |
| `"full"` (default) | Everything: the request, model prompts and responses, tool arguments and results, the answer. A trace that holds what the model was sent can be read, evaluated, and learned from. |
| `"default"` | The privacy-first preset: the same without model prompts and responses. Under governance, tool arguments are then recorded as `[REDACTED]`. |

A preset fills each `record_*` switch you leave unset; one you set always
wins:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from omnicoreagent import OmniCoreAgent

agent = OmniCoreAgent(
    name="support",
    system_instruction="Answer in plain text.",
    model_config={"provider": "openai", "model": "gpt-5.4-mini"},
    telemetry_config={
        "capture": "full",
        "record_tool_results": False,  # keep everything but what the tools returned
    },
)
```

| Switch | Records |
| - | - |
| `record_inputs` | Every input. Off, none is recorded, whatever the switches below say. |
| `record_outputs` | Every output. Off, none is recorded. |
| `record_model_prompts` | The messages and tool list sent to the model on each call. |
| `record_model_responses` | What the model answered on each call. |
| `record_tool_results` | What each tool, MCP tool, file operation and sandbox command returned. |
| `record_token_details` | The tokens the model chose and their probabilities, when the provider returns them (`logprobs`). Off by default: they are large. |

Everything recorded passes through the redaction of `redact_keys` (values of
keys like `api_key`, `token`, `password` become `[REDACTED]` at any depth)
and the [privacy filter](https://docs-omnicoreagent.omnirexfloralabs.com/docs/core-concepts/privacy.md) (personal data, in the
trace only, never in the run). A payload over `max_payload_bytes` (64,000)
is cut to a marker with its size and checksum, unless it is
[offloaded](#large-payloads). Each payload carries its capture state, and
[Read a run](https://docs-omnicoreagent.omnirexfloralabs.com/docs/how-to-guides/read-a-run.md#what-the-record-does-not-hold)
shows how a trajectory reports what is missing.

## Where traces are kept

| `storage` | Where |
| - | - |
| `"auto"` (default), `"jsonl"` | On local disk: `telemetry/traces.jsonl` in the workspace directory (`./workspace` unless configured), even when the workspace itself is S3 or R2. `storage_path` puts it elsewhere. |
| `"memory"` | In this process only, up to `memory_max_traces` (1,000) finished traces. |

The log holds the traces still running. A finished trace moves to an archive
beside it (`telemetry/traces-archive/`): trace bodies packed into segment files and a SQLite
index, so reading one trace does not read them all. Several server processes
can share one archive: `archive_index_url` makes the index a shared database,
and `archive_target: "object_storage"` keeps the bodies in the workspace's
bucket ([Stores and scale](https://docs-omnicoreagent.omnirexfloralabs.com/docs/how-to-guides/stores-and-scale.md)).

Recording never fails a run. A write that fails or takes longer than
`persistence_timeout_seconds` (5) is reported, and the trace is marked
`incomplete: True` with `evidence_status` `partial`. With `strict: True` the
error is raised instead. A trace's `metadata["telemetry_storage"]` says where
it was kept (`jsonl` or `memory`).

## Read the raw trace

The trajectory is the readable view; the trace is the record as stored,
spans and events, as a dict. With the run above:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import asyncio
from omnicoreagent import OmniCoreAgent

agent = OmniCoreAgent(
    name="weather",
    system_instruction="Use get_weather. Answer in plain text, in one sentence.",
    model_config={"provider": "openai", "model": "gpt-5.4-mini"},
)

async def main():
    trace = await agent.get_trace(run_id="run-weather-1")
    print(trace["trace_id"], trace["status"], trace["evidence_status"], trace["incomplete"])
    print("kinds:", sorted({span["kind"] for span in trace["spans"]}))

    latest = await agent.get_latest_trace("demo")
    normalized = await agent.get_trace(latest["trace_id"], normalize=True)
    print("normalized events in order:", [e["sequence_number"] for e in normalized["events"]][:8])

    family = await agent.get_trace_family(trace_id=trace["trace_id"])
    print("family:", [t["agent_id"] for t in family])
    print("in session demo:", len(await agent.list_telemetry_traces(session_id="demo")))

    events = await agent.get_telemetry_events_after(
        cursor=None, run_id="run-weather-1", event_types=("tool_result", "final_answer")
    )
    for event in events:
        print(event.stream_cursor, event.event_type, event.output)
    newer = await agent.get_telemetry_events_after(cursor=events[-1].stream_cursor, run_id="run-weather-1")
    print("after the last cursor:", newer)

asyncio.run(main())
```

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
trace_a593f1dedf4b4e26a57dd97b577e7a2c completed complete False
kinds: ['agent.run', 'agent.step', 'context.assembly', 'memory.read', 'memory.write', 'model.call', 'tool.batch', 'tool.call']
normalized events in order: [1, 2, 3, 4, 5, 6, 7, 8]
family: ['weather']
in session demo: 1
21 tool_result {'tool_name': 'get_weather', 'args': {'city': 'Nairobi'}, 'status': 'success', 'data': {'city': 'Nairobi', 'temperature_c': 25}, 'message': None}
33 final_answer {'response': 'The weather in Nairobi is 25°C.', 'status': 'success', 'termination_reason': 'stop'}
after the last cursor: []
```

| Call | Returns |
| - | - |
| `get_trace(result["trace_id"])` | That trace, or `None` |
| `get_trace(run_id=result["run_id"])` | The latest trace with that run ID. A run that paused has one per segment; under OmniServe the server's own request trace shares the run ID, so it may be that one. `get_trajectory(run_id=...)` picks the agent's. |
| `get_latest_trace(session_id)` | This agent's latest trace in the session |
| `get_trace(..., normalize=True)` | Spans sorted by start, events by sequence, with capture gaps and missing references marked |
| `get_trace_family(trace_id=...)` | The trace with its parents and children (sub-agents), each parent before its children |
| `list_telemetry_traces(...)` | Every trace matching `run_id`, `session_id`, `task_id`, `agent_id`, `workflow_id`, `model` or `status`, oldest first |

## The live event stream

Every event gets a `stream_cursor`, an opaque string that increases with
every event. Keep the last one you saw to carry on from there.

| Call | Does |
| - | - |
| `await agent.get_telemetry_stream_cursor(...)` | The position now. Take it before a run to follow the run from its first event. |
| `agent.stream_telemetry_after(cursor=..., ...)` | Yields the events after the cursor, then each new one as it is recorded. It does not end on its own. |
| `await agent.get_telemetry_events_after(cursor=..., ...)` | The events after the cursor, as a list, at once. Poll with the last `stream_cursor`. |

Each takes `trace_id`, `run_id`, `session_id`, `task_id` and `event_types`
to narrow it; `cursor=None` starts from the first stored event. A reader
that falls 1,000 events behind is stopped with `Telemetry stream queue
overflow; reconnect from a cursor` rather than silently skipping events.

Over HTTP, [OmniServe](https://docs-omnicoreagent.omnirexfloralabs.com/docs/how-to-guides/omniserve.md) streams a run while
it runs (`POST /run`), and serves the stored record under `/telemetry`. Add
`?run_id=` to isolate one run in a shared session:

```bash theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl "http://localhost:8000/telemetry/events?session_id=research_1&run_id=RUN_ID"
curl "http://localhost:8000/telemetry/events?run_id=RUN_ID&event_type=tool_result&limit=100"
curl -N "http://localhost:8000/telemetry/events/stream?session_id=research_1&run_id=RUN_ID"
curl "http://localhost:8000/telemetry/traces?session_id=research_1&limit=20"
curl "http://localhost:8000/telemetry/traces/TRACE_ID"
curl "http://localhost:8000/telemetry/runs/RUN_ID/trace"
curl "http://localhost:8000/telemetry/runs/RUN_ID/family"
curl "http://localhost:8000/telemetry/sessions/research_1/trace"
```

The SSE stream sends each event with its cursor as the `id:`, so a client
that reconnects with `Last-Event-ID` (or `?cursor=`) carries on where it
stopped. The same events are behind `/events/{session_id}?run_id=...`.

## Usage metrics

For a quick count without reading traces: each `run()` returns a `metric`
(`requests`, `request_tokens`, `response_tokens`, `total_tokens`,
`total_time`), and `await agent.get_metrics()` adds them up for this agent
object since it was built. `requests` counts model calls, not runs, and
`average_time` is per model call. The counts live in the process and start
again with it; OmniServe serves them at `GET /metrics`. For cost, and for
anything that must survive a restart, read the run's totals
([Read a run](https://docs-omnicoreagent.omnirexfloralabs.com/docs/how-to-guides/read-a-run.md#totals)).

## Exporters

The trace store needs no service. Exporters send a copy elsewhere: to any
OTLP/HTTP endpoint (an OpenTelemetry collector, or a vendor that takes OTLP),
LangSmith, Opik, or a JSONL file. Configure them on the agent to export each
trace when it ends, or export one when you choose:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import asyncio
from omnicoreagent import OmniCoreAgent, build_telemetry_exporter

agent = OmniCoreAgent(
    name="weather",
    system_instruction="Use get_weather. Answer in plain text, in one sentence.",
    model_config={"provider": "openai", "model": "gpt-5.4-mini"},
)

async def main():
    trace = await agent.get_trace(run_id="run-weather-1")
    jsonl = build_telemetry_exporter("jsonl", path="exports/one-off.jsonl")
    otlp = build_telemetry_exporter("otlp", endpoint="http://localhost:4318")  # nothing listening now
    for result in await agent.export_trace(trace["trace_id"], exporters=[jsonl, otlp]):
        print(result)
    try:
        await agent.export_trace(trace["trace_id"], exporters=[otlp], strict=True)
    except Exception as exc:
        print(type(exc).__name__, exc)

asyncio.run(main())
```

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
{'exporter': 'jsonl', 'trace_id': 'trace_a593f1dedf4b4e26a57dd97b577e7a2c', 'exported_spans': 14, 'exported_events': 33, 'destination': 'exports/one-off.jsonl', 'metadata': {}}
{'exporter': 'otlp', 'trace_id': 'trace_a593f1dedf4b4e26a57dd97b577e7a2c', 'exported_spans': 0, 'exported_events': 0, 'destination': None, 'metadata': {'error': 'OTLP export failed: [Errno 111] Connection refused', 'error_type': 'TelemetryExportError'}}
TelemetryExportError otlp export failed: TelemetryExportError: OTLP export failed: [Errno 111] Connection refused
```

An exporter that fails does not stop the others and does not fail the run:
its result carries the `error`. With `strict=True`, `export_trace` raises
instead. When an exporter configured on the agent fails at the end of a run,
the trace records a `telemetry_error` event naming the exporter.

`export_trace` exports one trace. A run that paused has one per segment, and
a run that delegated has one per child: `list_telemetry_traces(run_id=...)`
and `get_trace_family(trace_id=...)` list them to export each.

### Each destination

`telemetry_exporters` takes dicts (`destination` and the arguments below),
names, or exporter objects; `build_telemetry_exporter(destination, **arguments)`
builds one.

| `destination` | Arguments | From the environment | Needs |
| - | - | - | - |
| `"otlp"` (or `"otel"`, `"opentelemetry"`) | `endpoint`, `headers`, `service_name` (`"omnicoreagent"`), `timeout` (10 s) | `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT`, then `OTEL_EXPORTER_OTLP_ENDPOINT`; else `http://localhost:4318/v1/traces`. `/v1/traces` is added when missing. | `pip install "omnicoreagent[otel]"` |
| `"langsmith"` | `api_key`, `project_name`, `endpoint`, and the OTLP ones | `LANGSMITH_API_KEY`, `LANGSMITH_PROJECT` (or `LANGCHAIN_PROJECT`), `LANGSMITH_OTEL_ENDPOINT`; else `https://api.smith.langchain.com/otel/v1/traces` | `pip install "omnicoreagent[langsmith]"` |
| `"opik"` (or `"comet-opik"`, `"comet"`) | `api_key`, `workspace`, `project_name`, `endpoint`, and the OTLP ones | `OPIK_API_KEY`, `OPIK_WORKSPACE`, `OPIK_PROJECT_NAME` (or `OPIK_PROJECT`), `OPIK_OTEL_ENDPOINT`; else `https://www.comet.com/opik/api/v1/private/otel/v1/traces` | `pip install "omnicoreagent[opik]"` |
| `"jsonl"` | `path` (required) | none | nothing |
| `"memory"` | none | none | nothing; for tests (`exporter.traces`) |

LangSmith and Opik are the OTLP exporter with their endpoint and headers
filled in (`x-api-key` and `Langsmith-Project`; `Authorization`,
`Comet-Workspace` and `projectName`):

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
from omnicoreagent import OmniCoreAgent

agent = OmniCoreAgent(
    name="research-agent",
    system_instruction="You are a research assistant.",
    model_config={"provider": "openai", "model": "gpt-5.4-mini"},
    telemetry_exporters=[
        {"destination": "langsmith", "project_name": "production-agents"},  # key from LANGSMITH_API_KEY
        {"destination": "opik", "workspace": "your-workspace", "project_name": "production-agents"},
    ],
)
```

The LangSmith and Opik examples were not run for this page (they need an
account); the OTLP and JSONL ones were.

In OTLP, each span of the trace is a span, its events are span events,
and attributes carry `omnicoreagent.run_id`, `omnicoreagent.session_id`,
`omnicoreagent.evidence_status`, `gen_ai.system`, `gen_ai.request.model`,
and, on model calls, `gen_ai.usage.input_tokens` and
`gen_ai.usage.output_tokens`. An export at the end of a run is given up
after `export_timeout_seconds` (5). What is exported is what was recorded:
the same capture policy and redaction.

## Large payloads

A payload over `max_payload_bytes` is cut short. To keep it whole, offload
it: the trace keeps a reference, and the value is stored beside the traces:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import asyncio
from omnicoreagent import OmniCoreAgent, ToolRegistry

tools = ToolRegistry()

@tools.register_tool("read_log")
def read_log() -> str:
    """Read the service log."""
    return "\n".join(f"12:{i:02d} request served in {i * 7} ms" for i in range(60))

agent = OmniCoreAgent(
    name="logs",
    system_instruction="Read the log with read_log. Answer in plain text, in one sentence.",
    model_config={"provider": "openai", "model": "gpt-5.4-mini"},
    local_tools=tools,
    telemetry_config={"max_payload_bytes": 1000, "offload_large_payloads": True},
)

async def main():
    result = await agent.run("What was the slowest request in the log?")
    print(result["response"])
    trajectory = await agent.get_trajectory(result["trace_id"])
    call = trajectory["steps"][0]["tool_calls"][0]
    print(call["result"])
    print(call["result_capture"])
    whole = await agent.read_telemetry_payload(call["result_capture"]["reference"])
    print(type(whole).__name__, str(whole)[:120])
    await agent.cleanup()

asyncio.run(main())
```

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
The slowest request was at 12:59, served in 413 ms.
{'offloaded': True, 'target': 'workspace', 'reference': 'telemetry://payload/1263d8657aba23b08d65ab0fcddce8ab9d2b9663bc6e364f8cdc753550022f85', 'original_bytes': 1988, 'content_type': 'application/json', 'checksum': '1263d8657aba23b08d65ab0fcddce8ab9d2b9663bc6e364f8cdc753550022f85'}
{'state': 'offloaded', 'reason': None, 'reference': 'telemetry://payload/1263d8657aba23b08d65ab0fcddce8ab9d2b9663bc6e364f8cdc753550022f85'}
dict {'args': {}, 'data': '12:00 request served in 0 ms\n12:01 request served in 7 ms\n12:02 request served in 14 ms\n12:03 r
```

The payload is stored redacted, named by its checksum, in
`telemetry/payloads/` in the workspace, or in the workspace's S3 or R2
bucket with `offload_target: "object_storage"`. This is the trace's copy;
what the model saw is set by [tool offload](https://docs-omnicoreagent.omnirexfloralabs.com/docs/core-concepts/context-engineering.md),
separately.

## How long traces are kept

| Setting | Default | Removes |
| - | - | - |
| `retention_days` | `7` | Finished traces older than this, and **abandoned** traces: a trace still `running` with no activity for this long, because the process that recorded it died. A long run still working is never touched.Agents in one process that share a store must give the same value: a different one is refused when the second agent initializes, naming both. |
| `payload_retention_days` | `7` | Offloaded payloads older than this, except any a kept trace still refers to. |

`None` keeps everything. Retention runs once per agent, when it starts its
first run, and also when a process first reads its traces (such as a first
`get_run_trajectory`). To run it now, and see what it did:

```python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import asyncio
from omnicoreagent import OmniCoreAgent

agent = OmniCoreAgent(
    name="weather",
    system_instruction="Answer in plain text.",
    model_config={"provider": "openai", "model": "gpt-5.4-mini"},
    telemetry_config={"retention_days": 7, "payload_retention_days": 7},
)

async def main():
    print(await agent.prune_telemetry())
    status = agent.telemetry_retention_status()
    print(status["trace_store"])
    print(status["payload_store"])

asyncio.run(main())
```

```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
{'trigger': 'explicit', 'traces_removed': 0, 'payloads_removed': 0, 'payloads_retained_by_reference': 0, 'error': None, 'at': '2026-09-28T05:33:12.666599+00:00'}
{'retention_days': 7, 'last_prune': {'at': '2026-09-28T05:33:12.666534+00:00', 'trigger': 'explicit', 'retention_days': 7, 'removed': 0, 'abandoned': 0}, 'removed_total': 0, 'skipped_records': 0}
None
```

`last_prune` counts the traces removed and how many of them were abandoned;
`skipped_records` counts damaged lines found in the log (their traces are
marked `incomplete`). `payload_store` is `None` because this agent does not
offload payloads. OmniServe serves the status at `GET /telemetry/retention`.
Nothing you exported is touched.

A run's record is kept longer than its traces (30 days): see [how long a
run's evidence is
kept](https://docs-omnicoreagent.omnirexfloralabs.com/docs/core-concepts/durable-runs.md#how-long-a-runs-evidence-is-kept).

## How it works

**1. The loop records as it goes**

Each piece of work opens a span and each thing that happens is an event,
recorded through one recorder that applies the capture policy,
`redact_keys`, the privacy filter, and the payload size limit.

**2. Writes are batched and never block a run**

Records reach the store once per tick of the loop, on a writer thread,
and the trace is flushed to disk before the run returns.

**3. Subscribers get each event once**

Every event gets the next cursor; live subscribers receive it as it is
written, and readers from a cursor get the stored ones after it, from the
log and the archive.

**4. At the end, the trace is exported**

When a trace ends, each configured exporter gets it, with each model
call's whole request, and any failure is recorded in the trace.

## Options

In `telemetry_config`:

| Key | Default | What it does |
| - | - | - |
| `capture` | `"full"` | `"full"` or `"default"` (no model prompts or responses) |
| `record_*` | from `capture` | The switches in [What a trace records](#what-a-trace-records) |
| `storage`, `storage_path` | `"auto"`, workspace | `auto`/`jsonl` on disk, or `memory` |
| `retention_days`, `payload_retention_days` | `7`, `7` | How long traces and offloaded payloads are kept |
| `max_payload_bytes`, `offload_large_payloads`, `offload_target` | `64000`, `False`, `"workspace"` | Large payloads |
| `redact_keys` | `api_key`, `token`, `password` and others | Replaced, not added to: keep the defaults you want |
| `strict` | `False` | Raise when a record cannot be made safely, or an export fails |

Every key, including the archive settings and timeouts, is in the
[telemetry settings reference](https://docs-omnicoreagent.omnirexfloralabs.com/docs/reference/telemetry-config.md). On the
agent: `telemetry_exporters=[...]`. Methods, in the [OmniCoreAgent
reference](https://docs-omnicoreagent.omnirexfloralabs.com/docs/reference/omnicoreagent.md): `get_trace`, `get_latest_trace`,
`get_trace_family`, `list_telemetry_traces`, `get_telemetry_stream_cursor`,
`stream_telemetry_after`, `get_telemetry_events_after`, `export_trace`,
`read_telemetry_payload`, `prune_telemetry`, `telemetry_retention_status`,
`get_metrics`.

## When things go wrong

> [accordion] ValueError: telemetry capture must be one of: default, full
>
> There are two presets. To record less than `"default"`, turn off a
> `record_*` switch.

> [accordion] OTLP export failed: \[Errno 111] Connection refused
>
> Nothing is listening at the endpoint. The run is unaffected; the trace
> has a `telemetry_error` event, and it is still in the local store, so
> export it again with `export_trace` when the collector is up.

> [accordion] OpenTelemetry export requires the 'otel' extra
>
> The OTLP, LangSmith and Opik exporters need the OpenTelemetry packages.
> Without them nothing fails when the agent is built and the run is
> unaffected: an exporter configured on the agent fails at the end of each
> run, and the trace records the message in a `telemetry_error` event
> (`export_trace` returns it as the result's `error`):
>
> ```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
> OpenTelemetry export requires the 'otel' extra: pip install "omnicoreagent[otel]"
> ```

> [accordion] ValueError: Unknown telemetry exporter destination
>
> ```text theme={"theme":{"light":"github-light","dark":"github-dark"}}
> ValueError: Unknown telemetry exporter destination: datadog
> ValueError: Telemetry exporter config requires destination, type, or name
> ```
>
> The destinations are `otlp`, `langsmith`, `opik`, `jsonl` and `memory`.
> For another backend that takes OTLP, use `otlp` with its endpoint and
> `headers`.

> [accordion] ValueError: No telemetry payload store is configured
>
> `read_telemetry_payload` needs `offload_large_payloads: True`; without
> it, large payloads are truncated and there is nothing to read back.

> [accordion] ValueError: Use only one of trace\_id, run\_id, or session\_id
>
> `get_trace` takes one way of finding the trace.

> [accordion] Telemetry stream queue overflow; reconnect from a cursor
>
> The reader of `stream_telemetry_after` fell 1,000 events behind. Start
> again from the last `stream_cursor` it got; nothing is lost.

> [accordion] The traces are gone after a restart
>
> With `storage: "memory"` they live in the process. The default keeps
> them on disk, in `./workspace/telemetry/` relative to where the process
> runs: a process started elsewhere, or in a container without a volume
> there, has its own.

## Next

> [card] [Read a run](https://docs-omnicoreagent.omnirexfloralabs.com/docs/how-to-guides/read-a-run.md)
>
> Every run read back step by step, including one that paused.

> [card] [Outcomes and training](https://docs-omnicoreagent.omnirexfloralabs.com/docs/how-to-guides/outcomes-and-training.md)
>
> Attach what a run turned out to be worth, and read runs back as training records.

> [card] [Headless runs](https://docs-omnicoreagent.omnirexfloralabs.com/docs/how-to-guides/headless-runs.md)
>
> Run from the command line and keep the evidence.

> [card] [Harbor](https://docs-omnicoreagent.omnirexfloralabs.com/docs/how-to-guides/harbor.md)
>
> Run the agent on benchmarks, with each trial's trajectory.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.