:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(engineering-analytics): label kickout count as failed queue attempts (#118575)
Georges-Antoine Assi5c550c4885be
diff --git a/products/engineering_analytics/SPEC.md b/products/engineering_analytics/SPEC.mdindex 06cea3569201..9d74724672f9 100644--- a/products/engineering_analytics/SPEC.md+++ b/products/engineering_analytics/SPEC.md@@ -132,6 +132,7 @@ The per-PR friction view is the exception, below: it also needs the `pull_reques#### `engineering_analytics_pr_friction`- One row per pull request merged in the last 30 days: what its author went through. Red stretches counted by what turned them green, re-runs that failed again, CI running time per push, the wait for the first approval, pushes after approval, merge-queue time and kickouts.+- `kickout_count` counts merge-queue gate attempts where any workflow run failed. A queue removes a pull request only when a check it requires fails, and the GitHub source does not record which checks those are, so a failed optional check also counts. The figure is an upper bound on queue removals. The column keeps its name because saved queries over the view select it.- The red and running time is the PR timeline replay (§6) written as set-based HogQL, so one query covers every pull request in the window. `tests/test_pr_friction.py` replays seeded pull requests through both and asserts they agree, the way the cost view is held to the Python cost model.- It counts friction and does not score it. Curves and weights are applied when the view is read, so a weight change needs no rematerialization.- Materialized on the managed-view schedule, because the replay is too heavy to run on every read. Each run replaces the table, so it only holds the pull requests inside the window.diff --git a/products/engineering_analytics/backend/facade/contracts.py b/products/engineering_analytics/backend/facade/contracts.pyindex 6118735c6e67..d846b3da5578 100644--- a/products/engineering_analytics/backend/facade/contracts.py+++ b/products/engineering_analytics/backend/facade/contracts.py@@ -2042,6 +2042,8 @@ class PullRequestFrictionBreakdown:pushes_after_approval: int | None# None when the pull request never entered the merge queue.queue_seconds: float | None+ # Gate attempts with a failed workflow run. A failed run of a check the queue does not require+ # leaves the pull request queued, so this is an upper bound on queue removals, not a count of them.kickout_count: int | Nonediff --git a/products/engineering_analytics/backend/logic/views/pr_friction.py b/products/engineering_analytics/backend/logic/views/pr_friction.pyindex c546e7ff8201..0df8c033b8b6 100644--- a/products/engineering_analytics/backend/logic/views/pr_friction.py+++ b/products/engineering_analytics/backend/logic/views/pr_friction.py@@ -79,6 +79,9 @@ FIELDS: dict[str, FieldOrTable] = {"pushes_after_approval": IntegerDatabaseField(name="pushes_after_approval", nullable=True),# NULL when the pull request never entered the merge queue."queue_seconds": FloatDatabaseField(name="queue_seconds", nullable=True),+ # Gate attempts with any failed workflow run. The GitHub source does not say which checks the queue+ # requires, so a failed optional check also counts: an upper bound on queue removals. The name stays+ # because saved queries over the view select it."kickout_count": IntegerDatabaseField(name="kickout_count", nullable=True),# A read filters on its own authorized source: the view unions every source, and a member can be denied some."source_id": StringDatabaseField(name="source_id"),diff --git a/products/engineering_analytics/backend/presentation/serializers/friction.py b/products/engineering_analytics/backend/presentation/serializers/friction.pyindex 42d6fb86fe7a..e8b8f798420f 100644--- a/products/engineering_analytics/backend/presentation/serializers/friction.py+++ b/products/engineering_analytics/backend/presentation/serializers/friction.py@@ -20,7 +20,7 @@ class FrictionGroupShareSerializer(DataclassSerializer):extra_kwargs = {"group": {"help_text": "ci (red CI and CI waits), review (waiting for the first approval), queue (merge-queue "- "time and kickouts), or rework (own failures and extra pushes)."+ "time and failed queue attempts), or rework (own failures and extra pushes)."},"score": {"help_text": "This group's part of the score, in the same 'x typical' unit. The parts add up."},}@@ -151,7 +151,11 @@ class PullRequestFrictionBreakdownSerializer(DataclassSerializer):},"pushes_after_approval": {"help_text": "Pushes after the first approval. Null without an approval."},"queue_seconds": {"help_text": "Time in the merge queue. Null when the pull request never entered it."},- "kickout_count": {"help_text": "Times the merge queue removed the pull request. Null without queue data."},+ "kickout_count": {+ "help_text": "Merge queue attempts where at least one workflow run failed. A failed check the queue "+ "does not require leaves the pull request in the queue, so this is an upper bound on the times "+ "the queue removed it. Null when the pull request never entered the merge queue."+ },}diff --git a/products/engineering_analytics/backend/presentation/views/friction.py b/products/engineering_analytics/backend/presentation/views/friction.pyindex 532bf87d2458..51a2e789a97f 100644--- a/products/engineering_analytics/backend/presentation/views/friction.py+++ b/products/engineering_analytics/backend/presentation/views/friction.py@@ -76,7 +76,7 @@ class FrictionActionsMixin(EngineeringAnalyticsViewSetBase):description=("Every author's friction over pull requests merged in the last 30 days, most first: red CI they did ""not cause, re-runs that failed again, CI waits, the wait for the first approval, merge-queue time and "- "kickouts, and rework. The score is a multiple of the typical author and never counts how much or how "+ "failed queue attempts, and rework. The score is a multiple of the typical author and never counts how much or how ""fast someone ships. Bots are excluded, and authors need at least 3 merged pull requests."),)@@ -133,7 +133,7 @@ class FrictionActionsMixin(EngineeringAnalyticsViewSetBase):description=("One merged pull request's friction as a multiple of the typical pull request, with the counts behind ""it: red CI by cause, re-runs that failed again, CI time per push, the wait for the first approval, "- "merge-queue time and kickouts, and rework. Covers pull requests merged in the last 30 days."+ "merge-queue time and failed queue attempts, and rework. Covers pull requests merged in the last 30 days."),)@action(detail=False, methods=["get"], pagination_class=None)diff --git a/products/engineering_analytics/frontend/generated/api.schemas.ts b/products/engineering_analytics/frontend/generated/api.schemas.tsindex 4b8c2888e9d4..4e1afece0056 100644--- a/products/engineering_analytics/frontend/generated/api.schemas.ts+++ b/products/engineering_analytics/frontend/generated/api.schemas.ts@@ -152,7 +152,7 @@ export const FrictionGroupEnumApi = {} as constexport interface FrictionGroupShareApi {- /** ci (red CI and CI waits), review (waiting for the first approval), queue (merge-queue time and kickouts), or rework (own failures and extra pushes).+ /** ci (red CI and CI waits), review (waiting for the first approval), queue (merge-queue time and failed queue attempts), or rework (own failures and extra pushes).** * `ci` - CI* * `review` - Review@@ -1491,7 +1491,7 @@ export interface PullRequestFrictionBreakdownApi {*/queue_seconds: number | null/**- * Times the merge queue removed the pull request. Null without queue data.+ * Merge queue attempts where at least one workflow run failed. A failed check the queue does not require leaves the pull request in the queue, so this is an upper bound on the times the queue removed it. Null when the pull request never entered the merge queue.* @nullable*/kickout_count: number | nulldiff --git a/products/engineering_analytics/frontend/generated/api.ts b/products/engineering_analytics/frontend/generated/api.tsindex 27bbb93f06f8..0a728f7b3267 100644--- a/products/engineering_analytics/frontend/generated/api.ts+++ b/products/engineering_analytics/frontend/generated/api.ts@@ -142,7 +142,7 @@ export const getEngineeringAnalyticsAuthorFrictionUrl = (}/**- * Every author's friction over pull requests merged in the last 30 days, most first: red CI they did not cause, re-runs that failed again, CI waits, the wait for the first approval, merge-queue time and kickouts, and rework. The score is a multiple of the typical author and never counts how much or how fast someone ships. Bots are excluded, and authors need at least 3 merged pull requests.+ * Every author's friction over pull requests merged in the last 30 days, most first: red CI they did not cause, re-runs that failed again, CI waits, the wait for the first approval, merge-queue time and failed queue attempts, and rework. The score is a multiple of the typical author and never counts how much or how fast someone ships. Bots are excluded, and authors need at least 3 merged pull requests.*/export const engineeringAnalyticsAuthorFriction = async (projectId: string,@@ -803,7 +803,7 @@ export const getEngineeringAnalyticsPullRequestFrictionUrl = (}/**- * One merged pull request's friction as a multiple of the typical pull request, with the counts behind it: red CI by cause, re-runs that failed again, CI time per push, the wait for the first approval, merge-queue time and kickouts, and rework. Covers pull requests merged in the last 30 days.+ * One merged pull request's friction as a multiple of the typical pull request, with the counts behind it: red CI by cause, re-runs that failed again, CI time per push, the wait for the first approval, merge-queue time and failed queue attempts, and rework. Covers pull requests merged in the last 30 days.*/export const engineeringAnalyticsPullRequestFriction = async (projectId: string,diff --git a/products/engineering_analytics/frontend/lib/friction.test.ts b/products/engineering_analytics/frontend/lib/friction.test.tsindex b9637d313ed6..59f8d20a431f 100644--- a/products/engineering_analytics/frontend/lib/friction.test.ts+++ b/products/engineering_analytics/frontend/lib/friction.test.ts@@ -26,7 +26,7 @@ describe('pullRequestFrictionFacts', () => {{ ...QUIET, master_red_count: 2, kickout_count: 1, push_count: 3, ci_wait_seconds: [600, 1200] },// pluralize joins the count and the noun with a non-breaking space.[- ['queue', 'Kicked out of the merge queue', '1'],+ ['queue', 'Failed merge queue attempts', '1'],['ci', 'Red, the default branch was failing', '2'],['ci', 'CI running', '30m over 3\u00a0pushes'],['rework', 'Extra pushes that ran CI', '2'],diff --git a/products/engineering_analytics/frontend/lib/friction.ts b/products/engineering_analytics/frontend/lib/friction.tsindex 6cc5b0522146..9ca59c3e9ef3 100644--- a/products/engineering_analytics/frontend/lib/friction.ts+++ b/products/engineering_analytics/frontend/lib/friction.ts@@ -14,7 +14,7 @@ export const FRICTION_GROUP_LABELS: Record<FrictionGroupEnumApi, string> = {}export const FRICTION_GROUP_DESCRIPTIONS: Record<FrictionGroupEnumApi, string> = {- queue: 'time in the merge queue from 30 minutes up to 4 hours, and up to 3 kickouts per pull request',+ queue: 'time in the merge queue from 30 minutes up to 4 hours, and up to 3 failed queue attempts per pull request',review: 'the wait for the first approval',ci: 'red CI by cause and re-runs that failed again, up to 3 of each per pull request, and CI time from 10 minutes up to 2 hours per push',rework: 'own failures fixed by a push (up to 3 per pull request), extra pushes, and pushes after approval',@@ -40,7 +40,7 @@ export function pullRequestFrictionFacts(pr: PullRequestFrictionBreakdownApi): Fconst ciSeconds = pr.ci_wait_seconds.reduce((sum, seconds) => sum + seconds, 0)const facts: [FrictionGroupEnumApi, string, string | null][] = [['queue', 'Time in the merge queue', duration(pr.queue_seconds)],- ['queue', 'Kicked out of the merge queue', count(pr.kickout_count)],+ ['queue', 'Failed merge queue attempts', count(pr.kickout_count)],['review', 'Wait for the first approval', duration(pr.first_approval_wait_seconds)],['ci', 'Red, passed on a re-run', count(pr.flake_red_count)],['ci', 'Red, the default branch was failing', count(pr.master_red_count)],diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex f6395f4a128f..9c21264e7765 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -13537,7 +13537,7 @@ export namespace Schemas {} as const;export interface FrictionGroupShare {- /** ci (red CI and CI waits), review (waiting for the first approval), queue (merge-queue time and kickouts), or rework (own failures and extra pushes).+ /** ci (red CI and CI waits), review (waiting for the first approval), queue (merge-queue time and failed queue attempts), or rework (own failures and extra pushes).** * `ci` - CI* * `review` - Review@@ -91586,7 +91586,7 @@ export namespace Schemas {*/queue_seconds: number | null;/**- * Times the merge queue removed the pull request. Null without queue data.+ * Merge queue attempts where at least one workflow run failed. A failed check the queue does not require leaves the pull request in the queue, so this is an upper bound on the times the queue removed it. Null when the pull request never entered the merge queue.* @nullable*/kickout_count: number | null;