# Observability

Export every run as an OpenTelemetry trace with GenAI semantic conventions to Jaeger, Tempo, Honeycomb, Datadog, Langfuse or Phoenix, and scrape Prometheus metrics.

Source: https://glamorous-boar.cloudvent.net/observability/

---

Every run is already a first-class trace inside AgenticMind (the **Trace** tab). Observability export sends those traces to the tools your team already runs.

## OpenTelemetry traces

When a run finishes, its recorded events are converted into one OpenTelemetry trace and exported over **OTLP/HTTP** (protobuf by default, or JSON). Conversion happens after the run from the persisted trace, so it is exact, re-exportable (IDs derive from the run ID) and costs nothing while the run executes.

### Span tree

| Span | Attributes |
|---|---|
| `invoke_workflow <project>` (root) | run ID, revision, status, total tokens and cost |
| one span per node invocation | loop iterations and retries are separate spans |
| `chat <model>` for model nodes | `gen_ai.operation.name`, `gen_ai.provider.name`, `gen_ai.request.model`, `gen_ai.response.model`, `gen_ai.usage.input_tokens`, `gen_ai.usage.output_tokens`, `gen_ai.usage.cost` |
| `invoke_agent <label>` for Agent / Reasoning / Tool Router | plus `gen_ai.agent.name` |
| `execute_tool <tool>` children | `gen_ai.tool.name`, timed from the recorded duration |
| span events | agent turns, retries, guardrail blocks and other node events |

Failures carry status `ERROR` and `error.type`.

**Content is opt-in** (`AGENTICMIND_OTEL_INCLUDE_CONTENT=1` or the Settings toggle), because inputs, outputs and tool arguments can contain personal data. When on, content is also written under the keys Langfuse and OpenInference (Phoenix) display.

### Configure with standard variables

<CodeBlock language="bash" filename=".env" showCopy={true}>

```
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318        # /v1/traces is appended
# OTEL_EXPORTER_OTLP_TRACES_ENDPOINT=...                 # used as-is
OTEL_EXPORTER_OTLP_HEADERS=Authorization=Bearer%20xyz    # k=v,k=v, percent-decoded
OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf                # or http/json (gRPC is refused)
OTEL_SERVICE_NAME=agenticmind
AGENTICMIND_OTEL_INCLUDE_CONTENT=0
```

</CodeBlock>

### Or configure in Settings

Avatar → **Settings** → **Observability** (admins) overrides the variables: endpoint, protocol, service name, content opt-in, and a **headers secret** (header values such as API keys stay in the encrypted secret store; the page shows header names only). Presets:

| Preset | For |
|---|---|
| OTel Collector / Jaeger / Tempo | `http://localhost:4318` |
| Langfuse Cloud | Its OTLP endpoint with `Authorization=Basic <base64 public:secret>` and `x-langfuse-ingestion-version=4` |
| Phoenix (local) | Arize Phoenix's OTLP endpoint |

**Send test span** verifies the connection; the section shows export counts and the last error.

Export runs in the background after each run and never slows or fails it. 429/502/503/504 and network errors are retried with backoff.

### Per-run tools

- **Trace tab → download OTLP/JSON** (`GET /api/runs/{id}/otlp`), to open a single run anywhere.
- **Re-export** a run: `POST /api/runs/{id}/export`.

## Prometheus metrics

`GET /api/metrics` serves Prometheus text format:

- runs by status, and an active-runs gauge;
- a run-duration histogram;
- node failures by type and code;
- model calls, tokens (by provider, model and direction) and cost;
- tool calls by tool and outcome.

Set `AGENTICMIND_METRICS_TOKEN` and scrapers must send `Authorization: Bearer <token>` (`METRICS_TOKEN_REQUIRED` otherwise). Counters reset when the API restarts, which Prometheus handles.

## Debugging with traces: a real example

A supervisor workflow took 72 s to answer one question. Its exported trace showed 45 s spent re-delegating a Wikipedia lookup that kept failing with HTTP 403 (bot policy). That trace led directly to permanent tool failures, `reasoning_effort` and provider retries; the same workflow then answered in 30–43 s. Traces turn "it's slow" into a specific cause.

## Limits

Traces are exported when a run ends (no live spans); a waiting run exports when it finishes. CLI runs and exported apps do not export yet. No OTLP logs or metrics push.

## Theory

What spans, traces and semantic conventions are and how to observe LLM systems: [Production AI systems](/learn/production-ai-systems/#observability).
