feat: OTel trace exporter - events.jsonl to Jaeger (post-mortem)

ARCHITECTURE 9-bis BUILT: one run = one OTel trace, deterministic id
(sha of run dir name); root span named by the question with the final
answer as attribute; INIT/ROUTE/EXPERT/ANSWER as nested component spans;
every llm.done/probe.done/fact.merged event one span; recursive child
runs (same events.jsonl, own run_ts, seq restarts) nest as per-run
spans. Post-mortem only - the run never touches the network.

floop/traces.py stdlib only; pushes OTLP/HTTP JSON to Jaeger v2
(docker on agentvps, 10.3.14.59:16686 UI / :4318 ingest, VPN-bound).
python -m floop.traces runs/<dir> | --latest N | --dry.

Verified: Pedro 09:15 run -> 393 spans (root 1193.8s, 128 llm spans),
read back via Jaeger API; fractal goal run nests to depth 6.
tests/traces.py 5/5; recorder 3/3; inspect 3/3.
This commit is contained in:
2026-10-27 12:34:44 +01:00
parent d6c5bed443
commit 6ea769b7d1
5 changed files with 568 additions and 12 deletions
+49
View File
@@ -418,3 +418,52 @@ PR-1 skim surfaces + unit-pattern signals + chunk ranking + {{cvt}} unit
fix; PR-2 opportunistic harvest + seen-index + link queue; PR-3 skim
notices to the machine. The lucky same-article case is NOT the design
target — the goal-aware harvest is.
---
# Tooling — OTel traces + Jaeger (2026-10-27, no run)
**Not a run — the observability half of the owner's 26/10 ruling** ('vull
poder fer com un debug amb l'IDE de programació, però a posteriori de
l'execució'): the flight recorder's `events.jsonl` now exports as
OpenTelemetry, and the viewer is Jaeger instead of a hand-grown report.
**What was built:**
- `floop/traces.py` (stdlib only): one run = one trace (deterministic id =
sha of the run dir name — stable UI links); root span named by the
question, final answer as attribute; INIT/ROUTE/EXPERT/ANSWER as nested
component spans; every `llm.done`/`probe.done`/`fact.merged`/... event
one span with its attributes; recursive child runs (same file, own
`run_ts`, `seq` restarts) nest as per-run spans. Post-mortem only: the
run itself never touches the network.
- Jaeger v2.22 all-in-one, docker on agentvps, bound to 10.3.14.59 only
(UI :16686, OTLP :4318) — reachable from the VPN, zero exposure by
itself; Emili's apache at 10.3.14.1 fronts it publicly.
- `python -m floop.traces runs/<dir>` pushes one run; `--latest N` the
newest; `--dry` builds without pushing. `tests/traces.py` 5/5.
**Live-found bugs (the reason this took an afternoon):**
1. Pre-reading the LAST event's timestamp before the loop poisoned the
midnight detector → every span +24h. Law now written down: the clock
is only ever fed in emission order.
2. `comp.out` spans were closed but never appended — the payload shipped
every event as an orphan under the root.
3. Child-run blocks share events.jsonl; run-spans got double-appended
(stack + direct append) → duplicate span ids, Jaeger rejects.
4. OTLP/JSON wants full proto enum names (`SPAN_KIND_INTERNAL`,
`STATUS_CODE_OK`) and rejects empty `parentSpanId` on the root.
5. Jaeger v2 serves the query API at `/api/traces/...` on :16686 (not
`/api/services` — gone in v2; not under `/jaeger/api/` for reads —
that route is the SPA catch-all).
**Verified against real runs:** the 09:15 Pedro run exports 393 spans —
root 1193.8s, INIT→ROUTE→EXPERT→ROUTE→EXPERT→ANSWER children, 128 llm
spans with call_seq/dur_s/prompt-file — read back from Jaeger's own API
(393 stored, service `floop`); the fractal `goal` run nests child runs
depth 6. Three traces pushed live. ARCHITECTURE §9-bis updated: BUILT
(post-mortem), LIVE in-process export still deferred.
**Emili's open item:** the vhost at oniricapps (he configures the apache
reverse proxy + LE cert for e.g. jaeger.oniricapps.com; the container is
already reachable at 10.3.14.59:16686 from his server).