The orchestrator runs long-lived on Render and processes tasks asynchronously, but there is no way to observe its health beyond tailing logs. Basic operational questions — how many tasks are in flight, how many completed vs failed, how long steps take, how much USDC has been released — currently require scraping logs or querying the vault. That makes it hard to build a status dashboard or an alert, and hard to notice a slow degradation.
Goal
Add GET /metrics exposing process- and task-level counters, and wire the counters into the task/step lifecycle so they reflect reality.
Requirements & constraints
- At minimum expose: process uptime; task counts (total / active / completed / failed); step counts (executed / failed / timed-out); total USDC released; and a step-duration summary (at least p50 / p95 / max).
- Counters live in a small in-process module and are incremented from the executor and the task lifecycle. Seed from the existing stores where possible (
orchestrator-store.ts, task-results.ts, activity-store.ts) so a restart doesn't zero everything that's already knowable.
- Keep it dependency-free for the first version — a plain counters object with increment helpers. Do not pull in a heavyweight metrics library.
Design decisions left to the implementer
- Output format. Plain JSON is the least-effort and easiest for the dashboard to consume; Prometheus text exposition is a reasonable alternative if you want Grafana compatibility. Pick one, document it, and keep the shape stable.
- How step durations are sampled/stored to compute percentiles without unbounded memory (e.g. a bounded reservoir or a fixed-size ring).
Edge cases to consider
- Concurrent tasks incrementing counters (JS is single-threaded, but async interleaving still needs correct increment ordering).
- A task that fails mid-flight must move out of
active and into failed, not linger in both.
Acceptance criteria
Relevant files
packages/orchestrator/src/server.ts, packages/orchestrator/src/executor.ts, new packages/orchestrator/src/metrics.ts, docs/development.md
Notes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.
The orchestrator runs long-lived on Render and processes tasks asynchronously, but there is no way to observe its health beyond tailing logs. Basic operational questions — how many tasks are in flight, how many completed vs failed, how long steps take, how much USDC has been released — currently require scraping logs or querying the vault. That makes it hard to build a status dashboard or an alert, and hard to notice a slow degradation.
Goal
Add
GET /metricsexposing process- and task-level counters, and wire the counters into the task/step lifecycle so they reflect reality.Requirements & constraints
orchestrator-store.ts,task-results.ts,activity-store.ts) so a restart doesn't zero everything that's already knowable.Design decisions left to the implementer
Edge cases to consider
activeand intofailed, not linger in both.Acceptance criteria
GET /metricsreturns the counters above plus uptime, in the chosen formatusdc_released_totalreflects released paymentsdocs/development.mdnpm testpassesRelevant files
packages/orchestrator/src/server.ts,packages/orchestrator/src/executor.ts, newpackages/orchestrator/src/metrics.ts,docs/development.mdNotes for contributors
If you'd like to work on this, comment below so we can assign it to you.
Questions welcome — see CONTRIBUTING.md for setup
and workflow.