Skip to content

feat(metrics): exclude out-of-scope runs from KPIs via (skip-metrics) marker#107

Open
ignaciosantise wants to merge 3 commits into
masterfrom
feat/exclude-draft-pr-runs-from-kpis
Open

feat(metrics): exclude out-of-scope runs from KPIs via (skip-metrics) marker#107
ignaciosantise wants to merge 3 commits into
masterfrom
feat/exclude-draft-pr-runs-from-kpis

Conversation

@ignaciosantise

@ignaciosantise ignaciosantise commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Why

The rn row on the E2E KPI dashboard hit P95 PR feedback of 62m (vs ~30m usual): one hung Android E2E job on a draft PR ran to its 60m timeout and, with only n=8 PR runs in the window, dominated the P95. More broadly, work-in-progress and ad-hoc runs shouldn't count toward KPIs at all:

  • Draft-PR runs — WIP, not real feedback.
  • Manual (workflow_dispatch) runs off the default branch — ad-hoc dev testing; the SDK repos have no branch filter, so these land in pass/flake today.
  • Scheduled / default-branch runs — these should count and are unaffected.

How

Workflows stamp a (skip-metrics) marker into their run-name for runs that are out of scope (draft PR, or workflow_dispatch off the default branch). It surfaces on the run as display_title. This PR filters those out centrally in fetch_runs, so every KPI script inherits it.

The exclusion decision lives in each workflow — where draft/branch context is free — which keeps the metric side a plain string match with no extra API calls.

Correctness notes

  • Pagination preserved: filtering happens after the raw page size is counted, so a page full of skipped runs won't stop paging early.
  • Non-marked runs untouched: schedule/push/ready-PR/default-branch runs never carry the marker.
  • Opt-in per repo: only repos that emit the marker are affected.

Rollout

Requires each workflow to emit the marker. In progress:

Until a repo emits the marker, its behavior is unchanged.

🤖 Generated with Claude Code

Draft PRs run WIP CI that shouldn't count toward pass/flake/p95/bug-catch
KPIs. A single hung Android E2E job on a draft PR (62m, cancelled at
timeout) recently dominated the rn P95 sample (n=8) and pushed the P95 PR
feedback KPI to 62m vs the usual ~30m.

Workflows now append a " (Draft)" marker to their run-name when triggered
by a draft PR (github.event.pull_request.draft), which surfaces as the
run's `display_title`. Filter these out centrally in fetch_runs so every
KPI script inherits the exclusion.

Filtering happens after the raw page size is counted, so pagination still
keys off the real page count — a page that's mostly drafts won't look
short and stop paging early. Non-PR runs (schedule/push) have no draft
context, so their run-name never carries the marker and they're unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@claude

claude Bot commented Jul 1, 2026

Copy link
Copy Markdown

Claude finished @ignaciosantise's task in 2m 0s —— View job


Review complete

  • Read changed file
  • Analyze diff
  • Post findings

✅ No issues found

The change is correct and well-structured. A few observations worth confirming:

  • Pagination is sound: count is computed from the raw $response (line 52) before the jq filter emits output (line 53), so the < 100 early-exit check keys off the full page size — drafts can't mask a full page and cause premature stop.
  • Null safety: (.display_title // "") correctly passes non-PR runs (schedule/push) through untouched, since their display_title won't carry the marker.
  • Empty-response guard: the existing [[ -z "$response" ]] break (line 42) prevents the filter jq from receiving a blank line, so no parse error risk.
  • Convention dependency: filtering relies on workflows consistently emitting (Draft) (exact casing/spacing) in run-name. Non-conforming repos are unaffected, which matches the opt-in rollout described in the PR.

Broaden the run-name marker from "(Draft)" to a generic "(skip-metrics)"
so workflows can exclude any out-of-scope run, not just draft PRs. The
workflow decides what's out of scope (draft PRs + manual/workflow_dispatch
runs off the default branch) since branch/draft context is free there;
this stays a plain string match with no extra API calls.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ignaciosantise ignaciosantise changed the title feat(metrics): exclude draft-PR runs from all KPIs feat(metrics): exclude out-of-scope runs from KPIs via (skip-metrics) marker Jul 1, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ignaciosantise ignaciosantise marked this pull request as ready for review July 2, 2026 14:13
Copilot AI review requested due to automatic review settings July 2, 2026 14:13

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the shared metrics helper in metrics/scripts/lib.sh so KPI scripts exclude workflow runs that are explicitly marked as out-of-scope via a (skip-metrics) marker in the run name (surfaced by the API as display_title). This centralizes KPI scoping without requiring additional API calls.

Changes:

  • Filter out runs whose .display_title contains (skip-metrics) in fetch_runs.
  • Preserve pagination behavior by computing the raw page size (count) before applying the filter.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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