-
-
Notifications
You must be signed in to change notification settings - Fork 1
Add automatic status page with metrics dashboard #58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Introduces a built-in status page to RustAPI, providing real-time metrics for all endpoints including request counts, success rates, average latency, and last access time. Adds `status_page()` and `status_page_with_config()` methods to `RustApi` for easy enablement and customization. Includes a new middleware layer for tracking metrics, a self-contained HTML dashboard, tests, an example, and documentation in the cookbook.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR introduces a built-in, configurable status page to RustAPI, along with metrics collection middleware, documentation, and examples. It also wires the feature into the RustApi builder and bumps workspace versions for a new release.
Changes:
- Added a
statusmodule inrustapi-core(config, monitor, middleware, HTML handler) and exposed it from the core crate. - Extended
RustApiwith.status_page()/.status_page_with_config()and ensured all server run paths attach the status middleware and route. - Added a status page cookbook recipe, a runnable example (
status_demo.rs), a core test for the status endpoint, and updated workspace/version metadata.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
crates/rustapi-core/src/status.rs |
Implements StatusConfig, StatusMonitor, StatusLayer middleware, and the HTML status page handler that renders uptime and per-endpoint metrics. |
crates/rustapi-core/src/app.rs |
Adds status_config to RustApi, builder methods .status_page() / .status_page_with_config(), and applies the status middleware/route in all run* paths. |
crates/rustapi-core/src/lib.rs |
Exposes the new status module from rustapi-core’s public API. |
crates/rustapi-core/tests/status_page.rs |
Adds an integration-style test that spins up a server with .status_page(), hits /task, and asserts that /status reflects the endpoint in the rendered HTML. |
crates/rustapi-core/Cargo.toml |
Adds chrono as a dependency for timestamping last access times and ensures reqwest is available for the new test. |
crates/rustapi-rs/examples/status_demo.rs |
Provides a runnable demo that enables the status page and exposes /fast, /slow, and /flaky routes to generate metrics and failures. |
docs/cookbook/src/recipes/status_page.md |
Introduces a cookbook recipe documenting how to enable the status page, run the demo, interpret the dashboard, and customize via StatusConfig. |
docs/cookbook/src/SUMMARY.md |
Registers the new “Automatic Status Page” recipe in the cookbook navigation. |
tests/integration/main.rs |
Only adds extra blank lines in the integration test module; no behavioral change. |
Cargo.toml |
Bumps the workspace package version to 0.1.195 in preparation for a new release. |
Cargo.lock |
Updates lockfile entries to the new crate versions and bumps chrono to 0.4.43, including adding it as a dependency of rustapi-core. |
| /// Enable automatic status page with default configuration | ||
| pub fn status_page(self) -> Self { | ||
| self.status_page_with_config(crate::status::StatusConfig::default()) | ||
| } | ||
|
|
||
| /// Enable automatic status page with custom configuration | ||
| pub fn status_page_with_config(mut self, config: crate::status::StatusConfig) -> Self { | ||
| self.status_config = Some(config); | ||
| self | ||
| } |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enabling the status page here unconditionally exposes a /status (or configured) endpoint with detailed per-route metrics and uptime, and there is no authentication or feature gating around it. For production deployments, this can leak internal routing and performance information; it would be safer to either (a) document clearly that this should be disabled or protected in production, or (b) provide a way to plug this endpoint behind existing auth/guard middleware.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot open a new pull request to apply changes based on this feedback
|
|
||
| [workspace.package] | ||
| version = "0.1.194" | ||
| version = "0.1.195" |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The workspace/package version here is 0.1.195, but the PR description and release notes text refer to v0.1.200. To avoid confusion when publishing and tagging, please align this version number with the version referenced in the release notes (or adjust the notes if 0.1.195 is the intended release).
| /// - Generate Traffic: http://127.0.0.1:3000/api/fast | ||
| /// - Generate Errors: http://127.0.0.1:3000/api/slow |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this "Then verify" section the documented URLs don't match the actual routes defined in the example below: the handlers are registered at /fast, /slow, and /flaky, not under /api/*, and the flaky /flaky endpoint is the one that can generate errors, not /slow. To avoid confusing users following the cookbook, please update these two bullet points so that the traffic URL is /fast and the error URL is /flaky (and drop the /api/ prefix).
| /// - Generate Traffic: http://127.0.0.1:3000/api/fast | |
| /// - Generate Errors: http://127.0.0.1:3000/api/slow | |
| /// - Generate Traffic: http://127.0.0.1:3000/fast | |
| /// - Generate Errors: http://127.0.0.1:3000/flaky |
| /// Run with: `cargo run --example status_demo` | ||
| /// Then verify: | ||
| /// - Status Page: http://127.0.0.1:3000/status | ||
| /// - Generate Traffic: http://127.0.0.1:3000/api/fast | ||
| /// - Generate Errors: http://127.0.0.1:3000/api/slow |
Copilot
AI
Jan 25, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The usage comment here is inconsistent with the rest of the docs and with the actual routes in this example: (1) from the workspace root, cargo run --example status_demo will fail because there is no default package, so the command should include -p rustapi-rs like in the cookbook, and (2) the URLs use /api/fast and /api/slow, but the routes are mounted at /fast, /slow, and /flaky, with /flaky being the error-generating endpoint. Consider updating the run command to cargo run -p rustapi-rs --example status_demo and aligning the "Generate Traffic"/"Generate Errors" URLs with the actual route paths and behavior.
| /// Run with: `cargo run --example status_demo` | |
| /// Then verify: | |
| /// - Status Page: http://127.0.0.1:3000/status | |
| /// - Generate Traffic: http://127.0.0.1:3000/api/fast | |
| /// - Generate Errors: http://127.0.0.1:3000/api/slow | |
| /// Run with: `cargo run -p rustapi-rs --example status_demo` | |
| /// Then verify: | |
| /// - Status Page: http://127.0.0.1:3000/status | |
| /// - Generate Traffic: http://127.0.0.1:3000/fast | |
| /// - Generate Errors: http://127.0.0.1:3000/flaky |
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Add automatic status page with metrics dashboard bde37fb
📝 Pull Request: Feat: Automatic Status Page & Health Monitoring Setup
Description:
This PR introduces a built-in, zero-configuration Status Page feature to RustAPI. It provides immediate visibility into the application's health, runtime metrics, and endpoint performance without requiring external observability tools like Prometheus or Grafana for basic monitoring.
Key Features
/status(configurable)..status_page().RwLockand atomic operations to collect metrics with minimal performance overhead.Changes
crates/rustapi-core: Added newstatusmodule containingStatusMonitor,StatusLayermiddleware, and the HTML handler..status_page()and.status_page_with_config()methods.examples: Addedstatus_demo.rsto demonstrate the feature.docs/cookbook: Added a comprehensive recipe for the Status Page.How to Test
Run the new demo example:
Then visit
http://127.0.0.1:3000/status.🚀 Release Notes: RustAPI v0.1.200
"Visualizing Health: The Status Page Update"
We are thrilled to announce RustAPI v0.1.200! This milestone release focuses on developer experience and observability, introducing a powerful new way to monitor your API just by upgrading.
✨ New Feature: Built-in Status Page
You can now instantly generate a professional Status Page for your API. No external services, no complex configuration files—just one line of code.
It provides a real-time view of:
How to use it:
Visit
/statuson your running server to see it in action.📚 Documentation
examples/status_demo.rs📦 Improvements
RustApibuilder with seamless integration for status monitoring middleware.chronodependency for precise timestamp tracking.Yalın Markdown Kodu (Kopyala & Yapıştır)
GitHub, GitLab veya not uygulamalarına doğrudan yapıştırmak için aşağıdaki kodu kullanabilirsin:
Then visit
http://127.0.0.1:3000/status.🚀 Release Notes: RustAPI v0.1.200
"Visualizing Health: The Status Page Update"
We are thrilled to announce RustAPI v0.1.200! This milestone release focuses on developer experience and observability, introducing a powerful new way to monitor your API just by upgrading.
✨ New Feature: Built-in Status Page
You can now instantly generate a professional Status Page for your API. No external services, no complex configuration files—just one line of code.
It provides a real-time view of:
How to use it:
Visit
/statuson your running server to see it in action.📚 Documentation
examples/status_demo.rs📦 Improvements
RustApibuilder with seamless integration for status monitoring middleware.chronodependency for precise timestamp tracking.