Skip to content

Conversation

@Tuntii
Copy link
Owner

@Tuntii Tuntii commented Jan 25, 2026

📝 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

  • Dashboard: A clean, responsive HTML status page served at /status (configurable).
  • Real-time Metrics: Tracks total requests, success rates, average latency, and last access time for every registered endpoint.
  • Zero Dependencies: The dashboard is rendered directly from the binary using embedded HTML, keeping the deployment artifact lightweight.
  • Plug-and-Play: Enabled via a single builder method: .status_page().
  • Thread-Safe Monitoring: Uses RwLock and atomic operations to collect metrics with minimal performance overhead.

Changes

  • crates/rustapi-core: Added new status module containing StatusMonitor, StatusLayer middleware, and the HTML handler.
  • RustApi Builder: Added .status_page() and .status_page_with_config() methods.
  • examples: Added status_demo.rs to demonstrate the feature.
  • docs/cookbook: Added a comprehensive recipe for the Status Page.

How to Test

Run the new demo example:

cargo run -p rustapi-rs --example status_demo

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:

  • System Uptime & Global Stats
  • Per-Endpoint Success Rates (instantly spot failing routes)
  • Average Latency (identify bottlenecks)

How to use it:

use rustapi_rs::prelude::*;

#[rustapi::main]
async fn main() -> Result<()> {
    RustApi::auto()
        .status_page() // 🚀 Instant observability
        .run("127.0.0.1:8080")
        .await
}

Visit /status on your running server to see it in action.

📚 Documentation

📦 Improvements

  • Enhanced RustApi builder with seamless integration for status monitoring middleware.
  • Added chrono dependency 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:

# 📝 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
* **Dashboard:** A clean, responsive HTML status page served at `/status` (configurable).
* **Real-time Metrics:** Tracks total requests, success rates, average latency, and last access time for every registered endpoint.
* **Zero Dependencies:** The dashboard is rendered directly from the binary using embedded HTML, keeping the deployment artifact lightweight.
* **Plug-and-Play:** Enabled via a single builder method: `.status_page()`.
* **Thread-Safe Monitoring:** Uses `RwLock` and atomic operations to collect metrics with minimal performance overhead.

### Changes
* **`crates/rustapi-core`**: Added new `status` module containing `StatusMonitor`, `StatusLayer` middleware, and the HTML handler.
* **RustApi Builder**: Added `.status_page()` and `.status_page_with_config()` methods.
* **`examples`**: Added `status_demo.rs` to demonstrate the feature.
* **`docs/cookbook`**: Added a comprehensive recipe for the Status Page.

### How to Test
Run the new demo example:

```bash
cargo run -p rustapi-rs --example status_demo

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:

  • System Uptime & Global Stats
  • Per-Endpoint Success Rates (instantly spot failing routes)
  • Average Latency (identify bottlenecks)

How to use it:

use rustapi_rs::prelude::*;

#[rustapi::main]
async fn main() -> Result<()> {
    RustApi::auto()
        .status_page() // 🚀 Instant observability
        .run("127.0.0.1:8080")
        .await
}

Visit /status on your running server to see it in action.

image

📚 Documentation

📦 Improvements

  • Enhanced RustApi builder with seamless integration for status monitoring middleware.
  • Added chrono dependency for precise timestamp tracking.

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.
@Tuntii Tuntii self-assigned this Jan 25, 2026
Copilot AI review requested due to automatic review settings January 25, 2026 01:17
@Tuntii Tuntii added the enhancement New feature or request label Jan 25, 2026
Copy link
Contributor

Copilot AI left a 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 status module in rustapi-core (config, monitor, middleware, HTML handler) and exposed it from the core crate.
  • Extended RustApi with .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.

Comment on lines +874 to +883
/// 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
}
Copy link

Copilot AI Jan 25, 2026

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.

Copilot uses AI. Check for mistakes.
Copy link
Owner Author

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"
Copy link

Copilot AI Jan 25, 2026

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).

Copilot uses AI. Check for mistakes.
Comment on lines +39 to +40
/// - Generate Traffic: http://127.0.0.1:3000/api/fast
/// - Generate Errors: http://127.0.0.1:3000/api/slow
Copy link

Copilot AI Jan 25, 2026

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).

Suggested change
/// - 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

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +11
/// 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
Copy link

Copilot AI Jan 25, 2026

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.

Suggested change
/// 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

Copilot uses AI. Check for mistakes.
Tuntii and others added 3 commits January 25, 2026 04:28
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link

Copilot AI commented Jan 25, 2026

@Tuntii I've opened a new pull request, #59, to work on those changes. Once the pull request is ready, I'll request review from you.

@Tuntii Tuntii merged commit bde37fb into main Jan 25, 2026
7 checks passed
github-actions bot pushed a commit that referenced this pull request Jan 25, 2026
Add automatic status page with metrics dashboard bde37fb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants