mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 22:02:59 -07:00
6ec068c2ab
Fix Metrics History Retention & Accuracy This PR addresses several issues identified in the repository's metrics collection and analysis pipeline: 1. **Increased History Retention**: Increased the rolling window in `metrics/index.ts` from 100 rows to 5000 rows. The previous limit was too small (holding only ~1.5 runs of data), which prevented meaningful delta calculations. 2. **Restored Backlog Age Metric**: Re-introduced `backlog_age.ts` to calculate the average age of the oldest 100 open issues. This provides visibility into backlog stagnation. 3. **Enhanced Throughput Accuracy**: Updated `throughput.ts` to distinguish between items **authored** by maintainers and items **processed** (merged/closed) by maintainers. This gives a more accurate measure of maintainer velocity. 4. **Added Bottleneck Analysis**: Introduced `bottlenecks.ts` to sample open PRs and identify if they are likely waiting on a maintainer review or an author's response. These changes will significantly improve the "Brain's" ability to identify trends and bottlenecks in the repository workflow. # Impact - More accurate 7-day and 30-day deltas for all metrics. - Better visibility into maintainer workload and backlog health. - Data-driven identification of whether bottlenecks are due to maintainer capacity or author responsiveness.
49 lines
1.3 KiB
TypeScript
49 lines
1.3 KiB
TypeScript
/**
|
|
* @license
|
|
* Copyright 2026 Google LLC
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
import { GITHUB_OWNER, GITHUB_REPO } from '../types.js';
|
|
import { execSync } from 'node:child_process';
|
|
|
|
try {
|
|
const query = `
|
|
query($owner: String!, $repo: String!) {
|
|
repository(owner: $owner, name: $repo) {
|
|
issues(states: OPEN, first: 100, orderBy: {field: CREATED_AT, direction: ASC}) {
|
|
nodes {
|
|
createdAt
|
|
}
|
|
}
|
|
}
|
|
}
|
|
`;
|
|
const output = execSync(
|
|
`gh api graphql -F owner=${GITHUB_OWNER} -F repo=${GITHUB_REPO} -f query='${query}'`,
|
|
{ encoding: 'utf-8' },
|
|
);
|
|
const data = JSON.parse(output).data.repository;
|
|
const issues = data.issues.nodes;
|
|
|
|
if (issues.length === 0) {
|
|
process.stdout.write(`backlog_age_days,0\n`);
|
|
} else {
|
|
const now = new Date().getTime();
|
|
const totalAge = issues.reduce(
|
|
(acc: number, issue: { createdAt: string }) => {
|
|
const created = new Date(issue.createdAt).getTime();
|
|
return acc + (now - created);
|
|
},
|
|
0,
|
|
);
|
|
const avgAgeDays = totalAge / issues.length / (1000 * 60 * 60 * 24);
|
|
process.stdout.write(
|
|
`backlog_age_days,${Math.round(avgAgeDays * 100) / 100}\n`,
|
|
);
|
|
}
|
|
} catch (err) {
|
|
process.stderr.write(err instanceof Error ? err.message : String(err));
|
|
process.exit(1);
|
|
}
|