Repository navigation
feat(orchestrator): Add refresh duration and completion lag metrics - #425
Merged
Merged
Conversation
morgan-wowk
force-pushed
the
orchestrator-sweep-metrics
branch
2 times, most recently
from
November 2, 2026 22:49
d7b523d to
75a55e6
Compare
morgan-wowk
force-pushed
the
orchestrator-sweep-metrics
branch
from
November 2, 2026 22:52
75a55e6 to
89b07cc
Compare
yuechao-qin
reviewed
Nov 2, 2026
yuechao-qin
left a comment
Collaborator
There was a problem hiding this comment.
(AI Assisted)
Approve with one change. The instrumentation is placed where it can see what it claims: the refresh timing is recorded in a finally:, so every visit counts including the early returns, and the completion lag is recorded after the session.commit() that makes the status durable, carrying the committed status rather than the launcher's. Both helpers degrade safely — a missing or naive ended_at returns instead of raising — and the advisory bucket boundaries are actually honoured, since the MeterProvider configures no Views. One measurement bug to fix first: the two phases overlap, so they are not a split of the refresh (m1).
| # | Severity | Topic |
|---|---|---|
| m1 | 🔹 minor | the two phases overlap, so queries + processing is not the refresh's duration |
| N1 | ▫️ nit | the PR body names the phases querying/processing; the code emits queries |
yuechao-qin
reviewed
Nov 2, 2026
yuechao-qin
approved these changes
Nov 2, 2026
morgan-wowk
force-pushed
the
orchestrator-sweep-metrics
branch
from
November 3, 2026 00:40
89b07cc to
8da2f52
Compare
Adds two histograms to the tangle.orchestrator meter: - container_execution.refresh.duration: each running container execution refresh's queries and processing time, by container_execution.refresh.phase. - container_execution.completion_lag.duration: the time from a container ending, as its launcher reports it, to the orchestrator committing its container execution's SUCCEEDED or FAILED status, by the committed container_execution.status. A SUCCEEDED container with missing outputs is committed, and recorded, as FAILED. Completion lag is recorded at most once per container execution: the running sweep only selects PENDING and RUNNING rows, and nothing moves a container execution back out of SUCCEEDED or FAILED. CANCELLED and SYSTEM_ERROR are set by the orchestrator itself, with no launcher-reported end, so they are not recorded. SKIPPED only applies to execution nodes, which never get a container execution. A missing or naive end time is skipped, and an end time ahead of the orchestrator's clock is recorded as 0 since OTel histograms drop negative values. The processing clock now starts where the queries clock stops, so the execution-node lookup is counted once, in queries, and the two phases add up to the refresh.
morgan-wowk
force-pushed
the
orchestrator-sweep-metrics
branch
from
November 3, 2026 03:51
8da2f52 to
aa4bb4e
Compare
Collaborator
Author
|
Verified locally in OSS orchestrator and known wrappers. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: The only view into how long the orchestrator's sweep takes per execution, and how long a finished task waits to be marked done, is a flood of per-visit INFO logs.
Objective: Measure both as metrics, so the per-visit logs can be removed in #419.
sequenceDiagram participant C as Container participant O as Orchestrator sweep participant DB as Database participant U as User C->>C: Container finishes Note over C,U: completion_lag starts. The task still shows RUNNING loop Every execution ahead of it in the running queue O->>DB: queries phase: pick the next row, load it, find its nodes O->>O: processing phase: launcher refresh, finish it if it ended Note over O,DB: one refresh.duration sample per visit end O->>DB: queries phase: this execution's turn O->>C: processing phase: the launcher reports the container ended O->>O: upload its log, read its outputs O->>DB: commit SUCCEEDED or FAILED Note over C,U: completion_lag stops DB-->>U: The task shows done and downstream tasks startcompletion_lagis the delay users feel between a task finishing and Tangle showing it as done.refresh.durationexplains a high lag: a high sample count means many visits were ahead of it, and long samples mean each visit was slow. Longqueriessamples point at the database, and longprocessingsamples point at the launcher or storage.container_execution.refresh.duration: seconds per running container execution refresh, split bycontainer_execution.refresh.phase. The two phases don't overlap and add up to the refresh. What contributes, by phase:queries: the select that picks the least recently refreshed PENDING or RUNNING row, which slows with database load and the number of active executions.queries: loading that row, including its JSON columns.queries: looking up its execution nodes.processing: the cancellation check, one pipeline run query per execution node.processing: the launcher refresh, for example a Kubernetes read or a Davies API call.processing: saving changed launcher data.processing: for an ended container, uploading its log, checking and reading its outputs, queueing downstream tasks, and cleaning up the workload.processing: for a cancelled one, uploading its log and terminating it.container_execution.completion_lag.duration: seconds from a container ending, as reported by its launcher, to the orchestrator committing its SUCCEEDED or FAILED status, by that committedcontainer_execution.status. What contributes: