You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Export traces and metrics over OpenTelemetry #1539
Hi! Right now the server only logs to stdout, and several recent problems were hard to see from there: a source stuck as queued (#1451), sync checkpoints skipping tickets (#1359), alignment re-queueing on an empty balance (#1381), a lane running days behind.
I'd like to add optional OpenTelemetry export. It stays off unless OTEL_EXPORTER_OTLP_ENDPOINT is set, so nothing changes for anyone who doesn't set it. The existing tracing spans get a tracing-opentelemetry layer, and a few metrics are added, labelled by knowledge base where it makes sense:
jobs: queue size and oldest wait per base and lane, outcomes, retries, duration
storage per base: chunks, facts, vectors, blob bytes (one grouped query every few minutes)
throughput and processing time per item and stage
model calls: latency, tokens, cost, errors by the existing classes (rate limited, out of credit, rejected, ...)
syncs: items listed, fetched and written, upstream status codes, last success
search latency per base
I'd send it as small PRs, each under 500 lines, starting with the setup plus the job queue metrics. Does this shape work for you? Happy to change anything.
Hi! Gentle nudge, no rush at all. The first slices are up as drafts so the shape is easy to see: #1540 (setup and queue size per base), #1541 (oldest wait) and #1543 (model call duration, tokens and outcome). Export stays off unless OTEL_EXPORTER_OTLP_ENDPOINT is set.
If the plan above works for you, I'll mark #1540 ready. If you'd rather change the metric names, the labels or the order, I'm happy to rework them first. Thanks!
Thanks for the plan and for the patience; sorry it took a while to answer. Yes, optional OTLP export that stays off unless OTEL_EXPORTER_OTLP_ENDPOINT is set works for us, and the drafts made the shape easy to see.
Having read the whole stack (#1540 to #1548), I'd like it smaller before it goes in. Most of the 1,800 lines go into carrying a base to every model call: CallObserver and CallRecord around all five call paths, with_observer, AppState::observed, about 20 call sites edited, and an extra base_of query after every job. Here's what I'd suggest:
No kb label on model-call metrics. Credit and rate limits belong to the model and the workspace's settings, not to a base, and per-base load already shows in the queue gauges. Without the base, utopia-llm can report through one process-wide hook set once in main (a OnceLock, so the crate still doesn't depend on OpenTelemetry), and the per-client observer, the AppState fields and the call-site edits all go away. Labels: model, task, outcome, plus kind on tokens.
A bounded task label.call_label is the first sentence of the system prompt, which is fine in a log line, but a metric label has to stay a small fixed set. If every system prompt starts with a constant sentence, keep it, and a test asserting that would help. Otherwise use fixed names (chat, tools, embed, …).
Job metrics labelled by kind and outcome only. That drops the base_of query per finished job. The queue gauges keep kb, and that's where a stuck base shows up. The JobOutcome::of / outcome_label refactor is good, please keep it.
Three PRs instead of seven, each against dev rather than stacked:
The OTel layer sits under the same EnvFilter as stdout, so utopia=debug spans get exported too. A separate filter on the OTel layer (default info) would keep the trace volume down.
Lighter tests: one in-memory exporter test per metric is plenty.
Storage, sync and search metrics from the original list can come later as their own small PRs. Thanks again, this will make the next #1381 much easier to see.
Thank you for reading the whole stack so carefully, and no worries at all about the wait. Your suggestions make sense, and they make the whole thing a lot smaller. I'll go with all of them:
No kb on model-call metrics. utopia-llm reports through one process-wide hook set once in main (a OnceLock, so no OpenTelemetry in the crate). The per-client observer, the AppState fields and the call-site edits go away. Labels: model, task, outcome, plus kind on tokens.
A bounded task label. I'll check whether every system prompt starts with a constant sentence. If they do, I'll add a test asserting it; if not, I'll use fixed names.
Job metrics labelled by kind and outcome only, without the base_of query, keeping JobOutcome::of / outcome_label.
#1556 and #1557 each build on #1540, so their diffs will shrink to a single commit once it merges. I'll update them onto dev then. #1541 and #1543 to #1548 are closed.
And on #1544, the EXPLAIN (ANALYZE, BUFFERS) numbers you asked for are posted, along with a small speedup for the "nothing new" case.
No rush at all, whenever you have time. Thank you!
Activity
The server can export its job queue size per base over OpenTelemetry …
The server exports how long the oldest due job has waited per base, l…
gedaiu commentedon Nov 28, 2026
Hi! Gentle nudge, no rush at all. The first slices are up as drafts so the shape is easy to see: #1540 (setup and queue size per base), #1541 (oldest wait) and #1543 (model call duration, tokens and outcome). Export stays off unless
OTEL_EXPORTER_OTLP_ENDPOINTis set.If the plan above works for you, I'll mark #1540 ready. If you'd rather change the metric names, the labels or the order, I'm happy to rework them first. Thanks!
WaylandYang commentedon Nov 29, 2026
Thanks for the plan and for the patience; sorry it took a while to answer. Yes, optional OTLP export that stays off unless
OTEL_EXPORTER_OTLP_ENDPOINTis set works for us, and the drafts made the shape easy to see.Having read the whole stack (#1540 to #1548), I'd like it smaller before it goes in. Most of the 1,800 lines go into carrying a base to every model call:
CallObserverandCallRecordaround all five call paths,with_observer,AppState::observed, about 20 call sites edited, and an extrabase_ofquery after every job. Here's what I'd suggest:No
kblabel on model-call metrics. Credit and rate limits belong to the model and the workspace's settings, not to a base, and per-base load already shows in the queue gauges. Without the base,utopia-llmcan report through one process-wide hook set once inmain(aOnceLock, so the crate still doesn't depend on OpenTelemetry), and the per-client observer, theAppStatefields and the call-site edits all go away. Labels:model,task,outcome, pluskindon tokens.A bounded
tasklabel.call_labelis the first sentence of the system prompt, which is fine in a log line, but a metric label has to stay a small fixed set. If every system prompt starts with a constant sentence, keep it, and a test asserting that would help. Otherwise use fixed names (chat,tools,embed, …).Job metrics labelled by
kindandoutcomeonly. That drops thebase_ofquery per finished job. The queue gauges keepkb, and that's where a stuck base shows up. TheJobOutcome::of/outcome_labelrefactor is good, please keep it.Three PRs instead of seven, each against
devrather than stacked:I'll review and merge them in that order.
Smaller things for the first PR:
EnvFilteras stdout, soutopia=debugspans get exported too. A separate filter on the OTel layer (defaultinfo) would keep the trace volume down.Storage, sync and search metrics from the original list can come later as their own small PRs. Thanks again, this will make the next #1381 much easier to see.
gedaiu commentedon Nov 29, 2026
Thank you for reading the whole stack so carefully, and no worries at all about the wait. Your suggestions make sense, and they make the whole thing a lot smaller. I'll go with all of them:
kbon model-call metrics.utopia-llmreports through one process-wide hook set once inmain(aOnceLock, so no OpenTelemetry in the crate). The per-client observer, theAppStatefields and the call-site edits go away. Labels:model,task,outcome, pluskindon tokens.tasklabel. I'll check whether every system prompt starts with a constant sentence. If they do, I'll add a test asserting it; if not, I'll use fixed names.kindandoutcomeonly, without thebase_ofquery, keepingJobOutcome::of/outcome_label.dev. I'll start with The server can export its job queue size and oldest wait per base over OpenTelemetry #1540, folding The server exports how long the oldest due job has waited #1541 into it and giving the OTel layer its own filter (defaultinfo), and trim the tests to one in-memory exporter test per metric. Then model calls and job outcomes, in that order. I'll close The server exports how long the oldest due job has waited #1541 and Model calls report their duration, tokens and outcome per base #1543 to Finished jobs report their outcome and duration per kind and base #1548 as the replacements open.Storage, sync and search will come later as their own small PRs. Thanks again!
The OTel layer has its own filter, info unless UTOPIA_OTEL_FILTER say…
gedaiu commentedon Nov 29, 2026
@WaylandYang thanks again for the suggestions. The three PRs are up in the shape you described, all green, in the order you asked for:
infoby default,UTOPIA_OTEL_FILTERto change it), and there's one in-memory exporter test per gauge.main(aOnceLock), with nokblabel, noAppStatefields and no call-site edits. Labels aremodel,task(fixed:chat,tools,embed) andoutcome, pluskindon tokens.kindandoutcomeonly, with nobase_ofquery, keepingJobOutcome::of/outcome_label.#1556 and #1557 each build on #1540, so their diffs will shrink to a single commit once it merges. I'll update them onto
devthen. #1541 and #1543 to #1548 are closed.And on #1544, the
EXPLAIN (ANALYZE, BUFFERS)numbers you asked for are posted, along with a small speedup for the "nothing new" case.No rush at all, whenever you have time. Thank you!
OTEL_EXPORTER_OTLP_PROTOCOL picks the transport and OTEL_TRACES_EXPOR…
The server can export its job queue size per base over OpenTelemetry …
The server exports how long the oldest due job has waited per base, l…
The OTel layer has its own filter, info unless UTOPIA_OTEL_FILTER say…
OTEL_EXPORTER_OTLP_PROTOCOL picks the transport and OTEL_TRACES_EXPOR…
The server exports the time and tokens of every model call, by model,…
The server exports how many jobs finish and how long they take, by ki…
The server can export its job queue size and oldest wait per base ove…
The server exports the time and tokens of every model call, by model,…
The server exports how many jobs finish and how long they take, by ki…
The server exports how many jobs finish and how long they take, by ki…