Skip to content

The server can export its job queue size and oldest wait per base over OpenTelemetry - #1540

Merged
WaylandYang merged 4 commits into
deeplethe:devfrom
re-cinq:feat/opentelemetry
Dec 2, 2026
Merged

WaylandYang merged 4 commits into
deeplethe:devfrom
re-cinq:feat/opentelemetry

Conversation

@gedaiu

@gedaiu gedaiu commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

Hi! This is the first of the three PRs for #1539: the setup and both queue gauges. #1541 is folded in, as suggested on #1539.

When OTEL_EXPORTER_OTLP_ENDPOINT is set, the server sends its traces and metrics over OTLP. When it is not set, nothing changes and the logs look exactly as before.

  • utopia.jobs.queue.size is the number of due queued and running jobs per base, lane and status. One grouped query refreshes it every 30 seconds. A retry that is not due yet is left out, the same way the worker skips it. A job is placed in its base through its kb_id, document or source, and a malformed kb_id lands under "none" instead of failing the count.
  • utopia.jobs.queue.oldest_wait is how long, in seconds, the oldest due queued job of each base, lane and status has waited. It reads from the same snapshot, so it adds no query.
  • The transport follows the standard OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf by default, as the OTel spec asks, or grpc. OTEL_TRACES_EXPORTER=none keeps metrics only. Together they let the server push straight into Prometheus's own OTLP receiver (--web.enable-otlp-receiver), which takes HTTP and no traces. I checked that against Prometheus 3.5 locally, and both queue gauges arrived.
  • The OTel layer has its own filter, info by default and overridable with UTOPIA_OTEL_FILTER. The global EnvFilter now applies to stdout only, so utopia=debug spans stay in the log and are not exported.

Tests: one in-memory exporter test per gauge, one for the refresh against the database, one checking that a debug span stays out of the export, and three for reading the endpoint.

I checked it against a local collector and both gauges showed up as expected. Model calls and job outcomes come next, as their own PRs against dev. Thanks for taking a look!

@WaylandYang

Copy link
Copy Markdown
Contributor

Thanks! I answered on #1539 with a suggestion to simplify the whole stack: drop kb from the model-call and job metrics so no call site needs editing, keep task bounded, and fold the seven PRs into three. For this one, please fold #1541 into it and give the OTel layer its own filter.

@gedaiu gedaiu changed the title The server can export its job queue size per base over OpenTelemetry The server can export its job queue size and oldest wait per base over OpenTelemetry Nov 29, 2026
@gedaiu
gedaiu marked this pull request as ready for review November 29, 2026 16:18
gedaiu added a commit to re-cinq/utopia that referenced this pull request Nov 30, 2026
The server can push its metrics to Prometheus over OTLP/HTTP (upstream deeplethe#1540)

@WaylandYang WaylandYang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this follows everything from #1539, and the separate filter and the protocol switch are both welcome. Merging. One optional follow-up: keeping only the HTTP transport would drop tonic and three related crates (reqwest is already in the tree). gRPC users can point at a collector with an HTTP receiver, so I'd take that small PR if you agree.

@WaylandYang

Copy link
Copy Markdown
Contributor

Approved — thanks! It's fallen behind dev, and GitHub won't let us update the branch from our side ("user doesn't have permission to update head repository"). Could you rebase it onto the latest dev and push? We'll merge as soon as CI is green.

…when OTEL_EXPORTER_OTLP_ENDPOINT is set (deeplethe#1539)

Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
…ane and status (deeplethe#1539)

Signed-off-by: Bogdan Szabo <bogdan@re-cinq.com>
…s otherwise (deeplethe#1539)

utopia=debug stays a stdout setting: the global EnvFilter now applies to the
fmt layer only, so debug spans are no longer exported. One exporter test per
metric is kept.
…TER=none keeps metrics only (deeplethe#1539)

http/protobuf is the default, as the OTel spec asks, and grpc stays one
variable away. Prometheus's own OTLP receiver takes HTTP and no traces, so
both are needed to push metrics straight to it.
@gedaiu
gedaiu force-pushed the feat/opentelemetry branch from 620458e to 5a5b29a Compare December 2, 2026 11:21
@gedaiu

gedaiu commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

@WaylandYang thank you so much for the review! Rebased onto the latest dev and pushed, CI is running now. And yes, I agree on keeping only the HTTP transport. I'll send that small PR once this one is in.

@WaylandYang
WaylandYang merged commit a17c57e into deeplethe:dev Dec 2, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants