Skip to content

feat(analytics): add latency histogram buckets to analytics summary#96

Open
brodapeethar wants to merge 2 commits into
emrekayat:mainfrom
brodapeethar:feat/latency-buckets
Open

feat(analytics): add latency histogram buckets to analytics summary#96
brodapeethar wants to merge 2 commits into
emrekayat:mainfrom
brodapeethar:feat/latency-buckets

Conversation

@brodapeethar

Copy link
Copy Markdown
Contributor

Summary

Adds latency bucket counts to the analytics API to provide investor-grade performance visibility for paid query execution. Analytics now returns execution time distribution across five latency bands without changing provider execution or payment behavior.

Changes

  • packages/shared/src/types.ts — Added LatencyBucket type ("<1s" | "1-3s" | "3-10s" | ">10s" | "unknown") and latencyBuckets: Record<LatencyBucket, number> to AnalyticsSummary
  • apps/api/src/lib/storage/serialization.ts — Implemented classifyLatency() and bucket computation in buildAnalyticsSummary(); zeroed buckets on empty storage; unknown/missing latency counted separately
  • apps/web/src/types.ts — Added latencyBuckets to AnalyticsResponse using the shared LatencyBucket type
  • apps/api/src/routes/public.test.ts — Updated empty-storage test to assert zeroed buckets; added dedicated test covering fast (500ms), medium (2s), slow (5s), very-slow (15s), and unknown (0ms) records

Closes

Closes #89

Add latencyBuckets field to AnalyticsSummary showing query execution time distribution across <1s, 1-3s, 3-10s, >10s, and unknown buckets.

Closes emrekayat#89
@vercel

vercel Bot commented Jun 29, 2026

Copy link
Copy Markdown

@brodapeethar is attempting to deploy a commit to the emrekayat's projects Team on Vercel.

A member of the Team first needs to authorize it.

@emrekayat

Copy link
Copy Markdown
Owner

Thanks for the PR. I checked this from the emrekayat account.

I cannot run a proper merge-ref review or merge it yet because GitHub reports the branch as CONFLICTING / DIRTY, and refs/pull/96/merge is not available. Please rebase or merge the latest main and resolve the conflicts first.

Once it is mergeable, I will recheck the analytics latency bucket logic, shared/web types, and the API tests.

@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@brodapeethar Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@brodapeethar

Copy link
Copy Markdown
Contributor Author

@emrekayat please review and merge

@emrekayat

Copy link
Copy Markdown
Owner

Thanks for the update. I rechecked the latest merge ref from the maintainer account after #112 landed, but this still is not merge-ready.

Commands run:

git diff --check main...pr-96-merge
npm run test --workspace @query402/shared
npm run test --workspace @query402/api -- src/routes/public.test.ts

Shared tests pass, but the API public route test fails:

public routes > returns latency bucket counts that classify queries by execution time
AssertionError: expected undefined to deeply equal { "<1s": 1, "1-3s": 1, "3-10s": 1, ">10s": 1, "unknown": 1 }

The new latencyBuckets data is not present in the /api/analytics response shape on the current merge ref. Please wire the computed buckets into the public analytics response and make sure it remains compatible with the newly merged price-outlier analytics fields.

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.

Add paid-query latency histogram to analytics API

2 participants