feat: add 404 page and serve metrics on separate port#35
Conversation
Handle non-ok responses from /api/page instead of silently catching. Track errorStatus as HTTP status code (number | null) to distinguish error states from loading state. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Wire existing NotFound component into DocsPage using errorStatus from page context. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add getInitialErrorStatus() to compute error state from initialPage and pathname, so SSR also shows NotFound component on missing pages. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace manual Flex/Headline/Text layout with Apsara EmptyState component for consistent empty state styling. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
PrometheusExporter now starts its own HTTP server on configurable port (default 9090). Removes /api/metrics route and mock request handler. Adds telemetry.port to config schema. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
Warning Rate limit exceeded
Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 25 minutes and 33 seconds. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR introduces error status tracking to the page context for displaying 404 and 500 error pages, refactors the NotFound component to use an EmptyState layout, removes the metrics API endpoint, refactors telemetry initialization to use PrometheusExporter with a configurable port, and consolidates request tracking by removing the Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@packages/chronicle/src/lib/page-context.tsx`:
- Line 57: The conditional using pathname.startsWith('/apis') is too broad and
matches routes like '/apis-foo'; update the check that currently reads something
like if (pathname === '/' || pathname.startsWith('/apis')) to only treat the
top-level apis route by changing it to check for pathname === '/apis' or
pathname.startsWith('/apis/') (i.e., if (pathname === '/' || pathname ===
'/apis' || pathname.startsWith('/apis/')) ), and make the same change for the
other occurrence that uses pathname.startsWith('/apis').
In `@packages/chronicle/src/pages/DocsPage.tsx`:
- Around line 13-14: The current DocsPage returns null for any errorStatus that
isn't 404, causing a blank screen on server errors; update the DocsPage
component's error handling (the block checking errorStatus and page) so that
when errorStatus is set and not 404 it renders a proper error/failure UI instead
of null—e.g., render an Error or ServerError component (or a generic error
message) for non-404 statuses, keeping the existing NotFound render for 404 and
preserving the existing page render when page is present.
In `@packages/chronicle/src/types/config.ts`:
- Line 73: The telemetry.port schema currently uses
z.number().optional().default(9090) and allows invalid TCP port values
(negatives, >65535, non-integers); update the schema for telemetry.port to
enforce an integer in the valid TCP range by adding integer, min and max
constraints (e.g., use
z.number().int().min(1).max(65535).optional().default(9090)) so only valid ports
are accepted while preserving the default.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 4be53968-c75d-415d-9f2e-4a2bab8b2088
📒 Files selected for processing (8)
packages/chronicle/src/lib/page-context.tsxpackages/chronicle/src/pages/DocsPage.tsxpackages/chronicle/src/pages/NotFound.module.csspackages/chronicle/src/pages/NotFound.tsxpackages/chronicle/src/server/api/metrics.tspackages/chronicle/src/server/plugins/telemetry.tspackages/chronicle/src/server/telemetry.tspackages/chronicle/src/types/config.ts
💤 Files with no reviewable changes (2)
- packages/chronicle/src/server/plugins/telemetry.ts
- packages/chronicle/src/server/api/metrics.ts
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Default imports fail in ESM — these packages only export named. Fixes build failure. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Tighten /apis route matching to avoid false positives on /apis-foo - Handle non-404 errors in DocsPage to avoid blank screen - Validate telemetry.port as int in 1-65535 range Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
/api/pageerrors in page context witherrorStatusstate instead of silently catchingEmptyStatecomponent when page not found (SSR + client-side)/api/metricsroute to separate port (default9090, configurable viatelemetry.port)Test plan
curl localhost:9090/metrics)/api/metricsroute returns 404🤖 Generated with Claude Code