DocsOperations
Production observability
Correlate requests, emit structured lifecycle events, inspect fixed-cardinality metrics, and expose reliable liveness and readiness probes.
Production-safe defaults
Outside development mode, Rahti writes newline-delimited JSON request records to stderr. Every response receives X-Request-Id; a missing or invalid incoming id becomes a random 128-bit identifier. Application code can read the current id with observability::request_id().
- Logs contain method and path, never query strings, request bodies, cookies, authorization headers, or response bodies.
- 4xx and slow responses are warnings; 5xx responses are errors.
- Public files and health probes are omitted from lifecycle totals by default, though every response still receives an id.
Configure before the router
use std::time::Duration;
use rahti::observability::{self, Observability};
observability::configure(
Observability::default()
.service_name("orders")
.slow_request(Duration::from_millis(750))
.accept_request_ids(true)
.with_readiness("database", || async {
database_ping().await.map_err(|error| error.to_string())
}),
);
let router = routes::router();The router snapshots the policy. Request logging can be disabled while keeping ids, probes, and metrics; disabling observability entirely still leaves health endpoints available.
Correlated application events
rahti::observability::record_with(
"info",
"checkout",
"order accepted",
rahti::serde_json::json!({ "orderId": order.id }),
);Metrics and probes
| Surface | Contract |
|---|---|
| observability::metrics() | Process-local counters for completed, active, 4xx, 5xx, slow, cumulative, and maximum duration. |
| GET /health | HTTP 200 when the process can serve HTTP; checks no dependency. |
| GET /ready | Runs configured dependency checks concurrently and returns 503 when one fails or times out. |
Rahti does not publish metrics itself. Export the label-free snapshot through an approved collector or authenticated internal API, and aggregate replicas in the monitoring system. Readiness checks must be cheap, side-effect free, and reserved for dependencies required to serve traffic.
