Repository navigation
perf(mcp-analytics): compute tool latency quantiles in one pass - #122813
pauldambra wants to merge 1 commit into
Conversation
Generated-By: PostHog Desktop Task-Id: 5f7d1523-7072-4662-a685-6723b9b62f9b
|
Merging to
After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here |
🤖 CI report
|
| First copy | Second copy | Lines | Tokens |
|---|---|---|---|
products/mcp_analytics/backend/hogql_queries/tool_quality_tables.py:385 |
products/mcp_analytics/backend/hogql_queries/tool_tables.py:529 |
16 | 84 |
✅ Duplication (TypeScript) — clean
New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.
|
Risk: No findings This PR replaces the separate p50/p95 Sentinel reviewed |
There was a problem hiding this comment.
Approved.
Contained read-only analytics change with targeted regression tests and no open substantive concerns. The trusted context reports a clean current-head review but does not specify its review state.
- Author wrote 47% of the modified lines and has 6 merged PRs in these paths (familiarity MODERATE).
- PostHog Review (Standard) reviewed the current head: no findings.
Gate mechanics and policy version
| Gate | Result | |
|---|---|---|
| prerequisites | ✓ | all clear |
| deny-list | ✓ | no deny categories matched |
| size | ✓ | 72L, 1F substantive, 88L/2F incl. docs/generated/snapshots — within ceiling |
| tier | ✓ | T1-agent / T1b-small (88L, 2F, single-area, perf) |
| stamphog 2.6.1 | .stamphog/policy.yml @ 6956635 · reviewed head 6956635 |
Problem
quantilecalls.float(row[3] or 0)lets NaN through, because NaN is truthy in Python.Changes
quantiles(0.5, 0.95)call, so p50 and p95 come from one sample.quantilesreturns NaN, not NULL, for an empty input. AnarrayMapmaps NaN back to NULL. It runs once for each output row, not once for each event.quantiles(...)(if(is_tool, duration_ms, NULL)), because HogQL accepts only one level forquantilesIf.How did you test this code?
Test rationale:
test_aggregates_scalars_and_intent_coveragenow checks exact p50 and p95 values, not only "not None". This catches swapped array indexes.test_returns_none_latency_when_durations_are_missingcatches NaN getting through top50_ms. No existing test covers a call with no duration.test_groups_by_day_in_ordernow checks latency for a bucket with durations and a bucket without them. This catches the NaN bug in the daily query.Release status
Docs update
None.
🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Agent: Claude Code, Claude Opus 5.5 (
claude-opus-5-5)/writing-pr-descriptions.gh pr list --search "mcp quantiles tool_tables") found no open PR.Created with PostHog Desktop