← Back to Pull requests

Record the duration of every Dispatcher operation #25535

Closed
unknown closed this pull request without merging on Oct 14, 2026 09:27 UTC
View on GitHub
unknown unknown commented on Oct 07, 2026 09:51 UTC
Author

What does this PR do?

Every Dispatcher operation now goes through one context manager, MetricsHelper.operation(): dispatch_batch, fetch_workflow, refresh_jobs, collect_artifacts, gather_batch_results, publish_report, and three new ones for the steps before any batch is dispatched: resolve_run and resolve_changes (resolution) and build_plan (planner). When the operation settles it emits:

  • operations.count and operations.failed, as before.

  • A new operation.duration distribution (seconds), tagged dispatcher.operation and dispatcher.operation.result (success or failure). Failed operations are included; the result tag separates them. It replaces artifacts.download.duration, which is now operation.duration{dispatcher.operation:collect_artifacts}.

  • Exactly one log line, with @dispatcher.operation, @dispatcher.operation.result and @dispatcher.operation.duration_seconds: INFO on success ("Operation fetch_workflow succeeded in 0.42s"), WARNING for a recovered failure (when an operation has several causes, such as a failed listing and failed downloads, each is an entry in @dispatcher.operation.failures with its own message and fields), ERROR with the traceback when an exception escapes. A validation failure logs once, with the pydantic detail in the traceback.
  • An escaped exception without a recorded cause logs Operation <name> failed: <error>. Cancelled operations, and gathering abandoned during shutdown, record nothing.

    To give the resolution steps a failure to settle on, resolve_run, changes_for_run and validate_checkout raise RunResolutionError instead of aborting; dispatch_tests aborts with the same message and exit code outside the operation. The separate "Revision resolution failed" and "Planning failed" error lines are now the operations' failure lines.

    with self._metrics.operation(Operation.REFRESH_JOBS) as op:
        try:
            async for page in self._client.list_workflow_jobs(...):
                jobs.extend(page.data.jobs)
        except Exception:
            op.fail("Failed to list workflow jobs", exc_info=True)
    

    Motivation

    Operation metrics only said whether an operation failed, and only failures were logged with their operation, so the dashboard could not show which operation is slow or link from an operation to its logs. Each call site also paired record_operation and log_failed_operation by hand on every exit path (about 20 calls), which was easy to get out of sync.

    Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)

  • Add qa/required if this PR needs QA validation, or qa/skip-qa if it does not. Exactly one of the two is required.

  • If you need to backport this PR to another branch, you can add the backport/<branch-name> label to the PR and it will automatically open a backport PR once this one is merged
  • Diff: 366 lines (+274 / -92) across 4 files Reviewer: HadhemiDD Review duration: 10055m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.43) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.43 · 366 lines diff across 4 files
    0.43
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.353
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #25535"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.7% (MEDIUM) · Higher = larger blast radius
    42.7%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 16.9% · Safe to merge
    16.9%