Observability
Every agent run’s ledger, OpenTelemetry traces and metrics, and the Prometheus endpoint.
Every agent run keeps a ledger: each step it took, in order, with a line a person reads. The same steps go to
OpenTelemetry as one trace per run, and counters go to /metrics and OTLP.
The run ledger
GET /agents/v1/runs/{id}/ledger (service key, the run's agent, or the run itself):
{
"run": "run_7f3c...",
"entries": [
{"id": "led_...", "run_id": "run_7f3c...", "seq": 1, "at": 1764633600000, "kind": "run.created", "status": "ok",
"duration_ms": null, "actor": "agent:claims_bot", "summary": "Run started by claims_bot: close claim 2", "detail": {...}},
{"kind": "sql", "status": "ok", "duration_ms": 3, "actor": "run:run_7f3c...",
"summary": "UPDATE in its world, 1 rows", "detail": {"sql": "update claims set ...", "params": 4, "rows": 1, "tool": "run_sql"}},
{"kind": "run.proposed", "actor": "run:run_7f3c...", "summary": "Proposed its changes to main, under policy large_claims", "detail": {"policy": "large_claims"}},
{"kind": "run.held", "actor": "policy", "summary": "Held for a person: it changes claims, a table under review"},
{"kind": "run.merged", "actor": "link:ops@example.com", "summary": "Merged 1 rows, approved by link:ops@example.com"}
],
"next": null
}| Kind | Recorded when |
|---|---|
run.created, run.held, run.merged, run.rejected, run.conflict, run.discarded, run.expired, run.undone | the event of the same name happens |
run.proposed | the run asks to merge (before the policy decides) |
run.propose_failed, run.approve_refused | a proposal or an approval fails |
sql | a statement runs through POST /runs/{id}/sql, the SDK's sql() or MCP's run_sql (failures too) |
tool | an MCP tool reads the run (run_changes, get_run) |
job.attempt | an attempt of an agent function's job ends |
job.succeeded, effect.<channel> | the event of the same name happens for the run |
statusisokorerror. A failed statement keeps its error indetail.error.actorsays who caused the step:service,agent:<name>,run:<id>,policy,link:<email>,job:<function>.detail.viaismcpfor steps taken through the MCP server.- SQL text is kept up to
observe.sql_text_bytes(4000) bytes; longer text is cut, withdetail.truncatedset and the full length indetail.sql_bytes.0keeps only the length. Parameter values are never kept, only their count. ?limit=(1 to 5000, default 1000) and?after=<entry id>page through it;nextis the last id of a full page.?format=jsonlanswers JSON lines (application/x-ndjson), one entry per line, forjqor a log pipeline.- The dashboard's run sheet shows the same ledger as a timeline, with each statement's SQL a click away.
What the ledger can't see: statements an agent runs straight through its run's database_url with a Postgres
driver. Those reach the engine without passing Forkbase. Their effect is still in the run's changes
(GET /runs/{id}/changes), its proposal and its merge, which are in the ledger.
Entries are written in batches a quarter of a second apart, so a burst of steps costs one transaction. Reading the
ledger writes what's waiting first. If the database can't keep up, entries beyond 10,000 waiting are dropped and
counted (forkbase_ledger_dropped_total); the run itself is never slowed or failed by its ledger.
Entries older than observe.retention_days (30) are deleted once a day; 0 keeps them.
OpenTelemetry
Set an OTLP/HTTP endpoint and Forkbase sends traces and metrics there, JSON over HTTP, to any OpenTelemetry collector, Grafana, Honeycomb, Datadog, Langfuse, Arize Phoenix or similar:
FORKBASE_OTLP_ENDPOINT=http://127.0.0.1:4318 forkbase start
# or the standard variables
OTEL_EXPORTER_OTLP_ENDPOINT=https://api.honeycomb.io OTEL_EXPORTER_OTLP_HEADERS=x-honeycomb-team=... forkbase start- One trace per run. Its id is made from the run's id, so every step of the run, recorded by any server or job, lands in the same trace.
- The run's own span,
invoke_agent <agent>, spans the run from start to end. It is sent when the run ends (merged, rejected, discarded or expired), withgen_ai.operation.name = invoke_agent,gen_ai.agent.name,gen_ai.agent.id,gen_ai.conversation.id(the run id),forkbase.run.intentandforkbase.run.outcome. - Each statement and tool call is a child span,
execute_tool run_sql(or the tool's name), withgen_ai.tool.name,db.system.name,db.query.text,forkbase.rowsand its duration; a failure has an error status. Every other ledger entry is a child span named by its kind. - Names and attributes follow the OpenTelemetry GenAI semantic conventions, so tools that understand agent traces show runs as agents, and their SQL as tool calls.
- Export never blocks a request: spans go out with each ledger batch, metrics every
observe.metrics_every_s(60). An endpoint that refuses or is down is logged, and nothing is retried.
Metrics
GET /metrics (Prometheus text) has, beside the server's own gauges:
| Metric | Type | Labels |
|---|---|---|
forkbase_ledger_entries_total | counter | kind, status |
forkbase_ledger_dropped_total | counter | |
forkbase_runs_total | counter | outcome: created, held, merged, rejected, conflict, discarded, expired, undone |
forkbase_agent_tool_duration_seconds | histogram | tool |
With an endpoint set, the same go out over OTLP as forkbase.ledger.entries, forkbase.ledger.dropped,
forkbase.runs and forkbase.agent.tool.duration. Counters start at zero when the server starts.
Configuration
[observe] in forkbase.toml; see Configuration.
[observe]
retention_days = 30
sql_text_bytes = 4000
otlp_endpoint = "http://otel-collector:4318"
service_name = "forkbase"
metrics_every_s = 60Something wrong or missing? Edit this page on GitHub or open an issue.