observability Plugin
Throughput
This is a different thing from `repository_throughput_metrics.md`. That document describes `Throughput::MetricContract`: a per-repository contract precomputed into versioned cache snapshots. This document describes two install-wide Prometheus counters the plugin exports to `/metrics` (see `docs/engineering/operations/metrics.md`) while enabled: | Metric | Meaning | |---|---| | `syrus_throughput_landing_units_total{unit_type}` | Successful landing attempts. `unit_type` is `auto_merge` or `merge_train` -- one attempt counts as one unit regardless of how many Jobs it lands. | | `syrus_throughput_jobs_landed_total` | Jobs landed via a successful landing attempt. A `merge_train` unit counts every member Job it landed; an `auto_merge` unit counts its one Job. |
Global Throughput Metrics (Prometheus)
This is a different thing from repository_throughput_metrics.md. That document describes Throughput::MetricContract: a per-repository contract precomputed into versioned cache snapshots. This document describes two install-wide Prometheus counters the plugin exports to /metrics (see docs/engineering/operations/metrics.md) while enabled:
| Metric | Meaning |
|---|---|
syrus_throughput_landing_units_total{unit_type} | Successful landing attempts. unit_type is auto_merge or merge_train -- one attempt counts as one unit regardless of how many Jobs it lands. |
syrus_throughput_jobs_landed_total | Jobs landed via a successful landing attempt. A merge_train unit counts every member Job it landed; an auto_merge unit counts its one Job. |
These do not replace, recompute, or read from the repository snapshots. They exist because that contract is repository-scoped, while /metrics needs a global cumulative total sampled independently of repository snapshot refreshes.
Sampling
Throughput::MetricsSampler follows Metrics::LandingSampler's shape and needs cursor-based cumulative logic (not a plain aggregate value), so it registers as a full sampler class via the manifest's metrics do ... sampler MetricsSampler end (see Syrus::PluginApi::Definition#metrics). #sample! runs on the shared control-plane tick (SampleGlobalMetricsJob, the same tick core samplers use -- no plugin-owned tick_interval) and folds every auto_merge Workflow or merge_train that finished successfully since the last tick into a cumulative, cache-mediated total -- a cursor over finished_at, set exactly once per attempt and never revised, so nothing is double-counted across ticks. #refresh_gauges!, called from that same shared registry on the /metrics scrape path, reconciles this process's counters to that cached total -- necessary because the Workflow/MergeTrain that finishes runs on a worker process, while /metrics is served by the web role only.
Disabled means absent, not zero
Like every plugin metric, both counters follow while_enabled semantics: disabling Throughput removes them from /metrics entirely rather than freezing them at their last value or reporting 0.
Metrics Dashboard tab
When the metrics_dashboard plugin is also enabled, Throughput contributes its own "Throughput" tab there (Throughput::MetricsDashboardTabs, registered under metrics_dashboard's hosted "metrics_dashboard:tab" point -- see plugins/metrics_dashboard/docs/syrus_docs/metrics_dashboard.md), charting both counters above (landing_units, grouped by unit_type, and throughput_jobs_landed). The tab is absent, not empty, whenever either plugin is disabled.
Repository Throughput Metrics
Repository throughput metrics are derived from existing durable Syrus records first. They are a contract for dashboards, chat answers, and future rollups; they do not require new persistence unless query cost or historical stability later demands it.
Scope
Metrics roll up per Repository. Global aggregates may be built by summing repository windows, but the repository contract is canonical.
Query shape
Each source table is loaded once per request with a single date range covering every window, and the per-window split happens in Ruby via in_range?. The SQL predicate is therefore only a prefilter and is allowed to return a superset; anything narrower must keep that property or windows will silently lose rows.
This matters for cost. Emitting one range per window and OR-ing them together cannot drive an index range scan — the planner matches only the leading equality column and filters the rest row by row, which turns these queries into full scans of the largest tables in the schema. The window columns are indexed for this access pattern (idx_runs_state_finished_at, idx_merge_trains_repo_finished_at, idx_job_approvals_approved_at, alongside the existing idx_steps_throughput_kind_state_finished and idx_jobs_repo_state_closure_finished).
Queries also select only the columns each metric reads. runs in particular carries several large text columns (prompt, agent_pr_body) that the output metrics never touch, and loading them dominates the response.
The current contract is produced by Throughput::MetricContract (in the throughput plugin) and returns:
{
version: 1,
repository_id: 123,
generated_at: "2026-07-31T12:00:00Z",
cache_status: "fresh",
windows: {
"1h" => { ... },
"4h" => { ... },
"24h" => { ... },
"7d" => { ... },
"last_active" => { ... }
}
}
Authenticated app clients can read the same contract for one repository at:
GET /api/v1/app/repositories/:id/throughput_metrics
The endpoint is scoped through the signed-in user's repository workspace memberships. The plugin precomputes one versioned snapshot per active repository every five minutes on the consumed polling queue, including repositories whose issue polling is disabled. Snapshots are fresh for ten minutes and retained for up to 24 hours so a refresh failure does not erase the last known metrics. The response adds cache_status: fresh, computed for the single cold-cache fallback, or stale. generated_at continues to describe when the metric windows were computed, not request time.
Refreshes are serialized per repository and also guarded by a five-minute shared-cache lease. Computation is bounded to four minutes, and an old owner never deletes the lease, preventing an expired owner from removing a newer owner's claim and allowing duplicate expensive rollup. A cold request may compute the snapshot once. If another process owns that computation and no retained snapshot exists, the endpoint returns 503 with throughput_snapshot_unavailable; it never substitutes plausible empty metrics. Failed refreshes leave the prior snapshot intact. Cache keys include both repository ID and MetricContract::VERSION, so a contract version bump cannot serve an older payload under the new contract.
The repository detail page also renders this contract on its own "Throughput" tab. It exposes a window selector, headline rates, confidence labels, sample counts, merge-train unit/job split, review funnel, and landing bottleneck signals. UI consumers should keep the API contract as the source of truth rather than duplicating metric derivation in React.
Windows
Standard windows are 1h, 4h, 24h, and 7d, ending at the requested now.
last_active is a fallback one-hour window ending at the latest observed repository activity when standard windows are empty. Activity can come from Job creation, Step completion, Workflow completion, PR feedback comments, or merge-train completion.
Every rate includes count, per_hour, sample_count, and confidence.
Confidence labels:
none- 0 sampleslow- 1-4 samplesmedium- 5-19 sampleshigh- 20+ samples
Sparse rates must be displayed with their confidence label rather than presented as stable throughput.
PR Creation Throughput
pr_creation.count counts only Syrus-authored PRs: Jobs whose successful pr_open Step finished in the window and whose Job has pr_number.
External and fork-review PRs are not mixed into that headline rate. They are reported only as explicit separate series:
pr_creation.series.syrus_authoredpr_creation.series.externalpr_creation.series.fork_review
pr_creation.total_observed_count is the sum of those observed series. Use it only when the UI is clearly showing a mixed-source total.
Source fields:
steps.kind = "pr_open"steps.state = "succeeded"steps.finished_atjobs.pr_numberjobs.external_pr_numberjobs.fork_review_pr_number
This avoids inventing a PR-created timestamp. If a PR exists but the original pr_open Step is unavailable, it is not counted as observed PR creation throughput.
Output Throughput
output.commits counts distinct non-blank runs.head_sha values from succeeded output-producing Runs in the window. It is an observed committed-output sample, not a full Git commit count, because Syrus does not currently persist every commit in a typed table.
output.loc parses runs.step_agent_diff first, then runs.agent_diff, and reports additions, deletions, net LOC, and sample size. Diffs without a captured patch increase unavailable_sample_count.
output.by_job exposes per-Job/PR samples where data is available. Each sample contains the Job id, PR source and PR numbers, observed commit count, run sample count, diff sample count, unavailable diff count, additions, deletions, and net LOC. This is still derived from persisted Syrus run snapshots; exact GitHub commit lists or file-level PR metadata can be added later under a new contract version if needed.
Output-producing Step kinds:
implementrespondanalyze_and_fixlanding_fixmerge_train_buildagent_rebasestack_agent_rebasepush_agent_rebasestack_base_agent_rebase
Source fields:
runs.head_sharuns.step_agent_diffruns.agent_diffruns.finished_atsteps.kind
Landing Throughput
landing.landing_units counts successful landing Workflows. A single auto_merge Workflow is one landing unit; a successful MergeTrain row is also one landing unit. Merge trains are counted from merge_trains so the unit and its member count survive even when the associated Workflow is not the best source of train shape.
landing.jobs_landed counts Jobs landed by successful landing units. A clean auto-merge contributes one Job; a merge train contributes its member count.
landing.attempts separates successful, failed, cancelled, and deferred landing attempts. Deferred attempts are cancelled landing attempts where the Job remains approved and will re-enter the landing queue.
landing.unit_types splits successful units into auto_merge and merge_train, with both landing-unit and jobs-landed counts.
landing.merge_train_size reports member counts for successful MergeTrain records in the window.
Latency definitions:
approved_to_landing_latency_seconds-successful landing workflow.started_at - jobs.approved_atlanding_start_to_closed_latency_seconds-jobs.finished_at - successful landing workflow.started_atgrader_phase_duration_seconds- first landing grader step start through
last landing grader step finish.
mergeability_rebase_wait_seconds- mergeability preflight and landing
rebase step time where those steps exist.
Other landing signals:
base_moved_regrade_count- landing units that needed a merge-train
base-moved regrade/rebase path.
reused_landing_validation_count- attempts where cached landing
validation skipped the redundant pre-merge grade path.
current_optimistic_capacity- a recent estimate from successful landing
unit wall time over the trailing 7 days. It includes sample count, confidence, average successful unit wall time, estimated landing units/hour, estimated jobs landed/hour, and average jobs per landing unit.
Source fields:
workflows.trigger_kind IN ("auto_merge", "merge_train")workflows.stateworkflows.started_atworkflows.finished_atjobs.approved_atjobs.finished_atjobs.closure_reasonsteps.kindsteps.started_atsteps.finished_atsteps.cancellation_reasonmerge_trains.finished_atmerge_trains.failure_reasonmerge_train_members
Landing Waste
Landing waste separates failed attempts from successful landing latency.
Fields:
failed_landing_attempts_per_successful_landing- failed or cancelled
landing units divided by succeeded landing units.
failed_or_cancelled_landing_workflow_seconds- duration spent in failed or
cancelled auto_merge and merge_train Workflows.
failed_or_cancelled_landing_workflow_count- count of failed or cancelled landing attempts.deferred_landing_attempt_count- cancelled landing attempts that preserved
approval and returned to the queue.
failed_train_cooldown_seconds- configured cooldown time attached to
failed merge trains in the window, excluding stale-base rebuild failures.
failed_train_cooldown_remaining_seconds- current remaining cooldown for
those failed merge trains.
rebase_churn_workflow_count- count ofrebaseandstack_rebaseWorkflows in the window.rebase_churn_seconds- duration ofrebaseandstack_rebaseWorkflows in the window.landing_blocking_rebase_count- failed or cancelled rebase/stack-rebase Workflows, treated as landing blockers.
Review Funnel
The review funnel tracks PR review flow from durable comments and approvals:
jobs_with_pr_feedback- unique Jobs with actionable
PrReviewComment#comment_created_at in the window.
jobs_with_feedback_before_approval- Jobs approved in the window that
had at least one actionable PR feedback comment at or before approval.
feedback_rounds- per-Job feedback rounds in the window. Syrus uses the
larger of feedback Workflow count (Workflow::TriggerKind.feedback_values — pr_comment/chat_feedback/external_pr_feedback) and actionable PrReviewComment batches when comments exist without a matching Workflow row.
feedback_rounds_by_job- per-Job samples with PR source, PR numbers,
total round count, Workflow round count, comment counts split by issue, review, and fork-review feedback, and first/last feedback and addressed timestamps.
jobs_approved_immediately_without_feedback- Jobs approved in the window
with no PR feedback comment at or before approval.
approval_sources- approval counts by durable source where available:
operator (operator and dashboard bulk), auto (auto_rule), github_review, and unknown.
approval_count- Jobs approved in the window, based onjobs.approved_at.approval_vote_count- rawJobApprovalvotes recorded in the window.pr_open_to_first_feedback_seconds- first PR feedback comment timestamp
minus successful pr_open Step completion.
feedback_to_addressed_seconds- handled feedback timestamp minus feedback
comment timestamp for actionable comments addressed in the window.
pr_open_to_approval_seconds/approval_latency_seconds-
jobs.approved_at - successful pr_open step.finished_at.
approval_to_landing_start_seconds/
approval_to_landing_latency_seconds - landing Workflow start minus jobs.approved_at.
approval_to_landed_seconds- successful Job close timestamp minus
jobs.approved_at.
Every duration payload includes sample size and confidence. Empty, cancelled, and no-change Jobs only contribute when the durable timestamp for the measured funnel stage exists; a cancelled or no-change Job without approval is not treated as an immediate approval.
Source fields:
pr_review_comments.comment_created_atpr_review_comments.pr_typepr_review_comments.comment_kindpr_review_comments.actionablepr_review_comments.handled_atpr_review_comments.actioned_atworkflows.trigger_kind IN Workflow::TriggerKind.feedback_values("pr_comment","chat_feedback","external_pr_feedback")workflows.created_atjobs.approved_atjobs.approved_viajob_approvals.approved_at- successful
pr_openStep completion
Admin Throughput API
Throughput::AdminMetricsPayload answers a different shape of question than the repository-scoped contract above: not "what is the current rate over these rolling windows for one repository?" but "how did throughput move bucket by bucket across an arbitrary since/until range, instance-wide or for one repository?" It backs:
GET /api/v1/admin/throughput
Bearer-token, admin-scoped (User#api_token), following the same before_action :require_admin_api pattern as core's /api/v1/admin/* diagnostics endpoints. With the plugin disabled, it answers { "error": { "code": "plugin_disabled" } } with a 404, matching admin_mysql and tailscale.
Query parameters:
repository- optional. Either a numeric Repository id or an
owner/name slug. Omitted means instance-wide.
since/until- optional ISO-8601 timestamps, consistent with
/api/v1/admin/runs?since=. Default window is the trailing 7 days ending now; the window is clamped to at most 90 days.
Response shape:
{
version: 1,
generated_at: "2026-09-06T12:00:00Z",
range: { since: "...", until: "..." },
repository: { id: 1, slug: "acme/widgets" } | nil,
hourly: { bucket_seconds: 3600, buckets: [ { ... } ] },
daily: { bucket_seconds: 86400, buckets: [ { ... } ] }
}
Each bucket reports:
bucket_start/bucket_end- UTC ISO-8601 boundaries.jobs_created- Jobs whosecreated_atfalls in the bucket.jobs_closed- Jobs whosestate = "closed"andfinished_atfalls in
the bucket, any closure reason. Job::TERMINAL_STATES also includes the legacy no_change_needed state; those rows are old/operator-forced repair transitions (current no-change closures already land in state: "closed" with closure_reason: "not_needed") and are intentionally not counted.
jobs_implemented- Jobs reachingimplementedin the bucket. Jobs have
no durable "reached implemented" timestamp column (the AASM transition is not event-logged), so this counts the first successful pr_open Step's finished_at per Job as a proxy -- the moment that transition happens for the overwhelming majority of Jobs. A Job that reaches implemented through another path without ever running a successful pr_open Step is not counted.
cycle_time_seconds-sample_count,median, andp90of
jobs.finished_at - jobs.created_at for Jobs closed with closure_reason = "pr_merged" whose finished_at falls in the bucket.
All timestamps are UTC. Stored columns are UTC while MySQL's session NOW() is not, and conflating them has produced wrong readings before (see the repository-root CLAUDE.md "Things that bit us" notes) -- this endpoint only ever emits Time#iso8601 on UTC-stored datetime columns.
Per-bucket resilience follows Admin::JobStateSerializer: a bucket that fails to compute emits { bucket_start:, error_serializing: "..." } instead of 500ing the whole response.
Persistence Policy
Do not add metric tables for this contract until a caller demonstrates one of:
- Query cost is too high for dashboard refresh.
- Historical stability requires freezing numbers after mutable source records change.
- External data such as exact GitHub PR creation timestamps, full commit
lists, or file-level additions/deletions becomes necessary.
If persistence is added later, persisted rollups must keep the same versioned contract shape or introduce a new version.
Plugin ownership
This feature lives in the throughput plugin, not core. The plugin owns Throughput::MetricContract, Throughput::AdminMetricsPayload, the throughput_metrics and /api/v1/admin/throughput endpoints, and the tab component, and contributes a "Throughput" tab to the repository detail page through the repo_page_tab extension point (Throughput::RepoPageTabs). Disabling the plugin removes the tab and both endpoints; nothing else on the page changes. Core has no reference to either contract -- bin/check-plugin-boundaries (and the slower opt-in bin/plugin-boundary-audit throughput) enforce it.