Make long window uptime honest#19
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 325dedcab7
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@kilemensi These were all alternatives I considered in #13:
Ultimately, the approach where we show an alert about the retention period is the one that covers most cases without turning the code into a nest of conditions. Disabling/hiding durations can be confusing for users and doesn't translate well either. This solution also covers people running self-hosted instances of Grafana with custom retention periods. One thing we should consider is inferring the retention based on the oldest data returned but outside the hot path i.e. we make a cheap, periodic query that determines how far back your data goes then cache that somewhere and use it for all other queries. I would be cautious though because if this query returned inaccurate data for some reason, there would be inconsistencies in the UI. |
ddfbf54 to
109176e
Compare
109176e to
65768cf
Compare
|
I hear you @maquchizi. I don't have the deeper context that you have so if this direction makes more sense all good. My point was, as a user, I'd like to see actions I can actually take i.e. make sense to me & my setup. There is no point in showing me a year option if all I have is 14d worth of data. You can still show a warning/info about this... and if we're pre-building pages, there shouldn't be any runtime cost of detecting the earliest available sample dynamically I believe. |
65768cf to
c029d2a
Compare

What & why
On the free Grafana Cloud plan only ~14 days of metrics are retained, but the status page presented the 30-day and 1-year windows as fully covered — reporting a confident, false
100%uptime (see #12). The app is read-only and can't recover dropped data, so this makes coverage honest and environment-driven instead of trying to recover history.METRICS_RETENTION_DAYSconfig (lib/config.ts, server-side). Unset ⇒ unlimited ⇒ no change for existing deployments; set to14for the free tier.—) rather than a misleading ratio over a partial range — on the overview list, the per-site uptime grid, and the window selector. Bonus: fewer Grafana queries per refresh.1yview shows the ~14 real days at usable density instead of a near-empty strip.30d→7dunder a 14-day plan) so visitors don't land on a grid of—.MOCK=1 METRICS_RETENTION_DAYS=14reproduces the behavior locally.Stays stateless and read-only; keeps all windows visible rather than removing them.
Closes #12
Closes #13
Type of change
Checklist
[AGENTS.md](https://claude.ai/AGENTS.md)and[CONTRIBUTING.md](https://claude.ai/CONTRIBUTING.md)pnpm checkpassespnpm testpasses (134 tests)pnpm test:typespassespnpm buildsucceeds.env.example,docs/configuration.md,docs/architecture.md)NEXT_PUBLIC_prefix —METRICS_RETENTION_DAYSis server-side and reaches Client Components only as a resolvedretentionDayspropNotes for reviewers
/site/api-sensorsafrica-africa?window=1y(the bad-state example from [Bug] Long time windows report 100% uptime when data is beyond the plan's retention #12) now shows—for the 30d/1y figures instead of a false100%, with the uptime strip and response chart clamped to 2 Jul – 16 Jul (14 days) rather than a sparse year.retentionSec()/coveredWindows()inlib/synthetics.ts,retentionSec()inlib/mock.ts) rather than as module-level constants — config is static in production, but this keeps the query-skip/clamp logic unit-testable by letting tests varyconfig.retentionDays.windowWithinRetentioncovers a window whose span is ≤ retention (so7dis covered at exactlyretentionDays=7).CoverageNoteis a Client Component used from both a client page (overview) and a server page (site detail); both share the same localStorage key, so a dismissal applies across surfaces.