ulo
ulo
Documentation

Start here

Coming from NestJSNestJS topics, mapped

The model

Protocols

Integrations

RecipesServe static filesCompress responsesSecurity headers and CSRFSessions with tower-sessionsCookies with tower-cookiesRequest IDsAccess logError reporting with SentryLocalised responses with FluentA client as a providerA MongoDB ODM over the injected clientExplicit transactions with SQLxA mailer over lettreObject storage over the AWS SDKA CLI command with clapMocks with mockallFeature flags with OpenFeatureAuthorization with CedarMoving from axum or actix-web

Operating

Reference

Recipes

Access log

One log line per request, with status and duration, from tracing-subscriber span-close events on the call span.

Each HTTP call runs in a call span that carries the method, path, route and status. A tracing_subscriber::fmt subscriber that reports FmtSpan::CLOSE prints one line when that span closes, at the end of the request. The line carries the status and the busy and idle time. No middleware is involved.

The recipe builds on examples/38-tracing and the span table in Logging and tracing. It compiled and ran on port 0 against tracing-subscriber 0.3 and tracing 0.1.

tracing = "0.1"
tracing-subscriber = "0.3"

The code

use tracing_subscriber::fmt::format::FmtSpan;
use ulo::{App, AppBuilder, controller, handlers, module};
use ulo_http::Path;

/// Installs the subscriber: one line per span when it closes, which for the HTTP call span is
/// the end of the request.
pub fn init() {
    tracing_subscriber::fmt()
        .with_span_events(FmtSpan::CLOSE)
        .with_target(false)
        .with_ansi(false)
        .init();
}

#[controller]
pub struct OrdersController;

#[handlers]
impl OrdersController {
    #[ulo_http::get("/orders/{id}")]
    fn order(&self, Path(id): Path<u32>) -> String {
        tracing::info!(order = id, "loading order");
        format!("order {id}")
    }
}

#[module(controllers = [OrdersController])]
pub struct AppModule;

pub fn builder() -> AppBuilder {
    App::builder(AppModule)
}

What each seam does

with_span_events(FmtSpan::CLOSE) makes the subscriber emit an event when a span closes, with time.busy and time.idle. The call span records http.response.status_code before it closes, so the closing line carries it. with_ansi(false) keeps colour codes out of a log file.

Observed output for GET /orders/7, GET /orders/abc and GET /nowhere, each line cut after its fields (ulo.handler and the duplicated otel.name fields are elided here and present in the real line):

2026-11-17T16:57:54.732409Z  INFO call{otel.name="GET" otel.kind="server" ulo.transport="http" http.request.method="GET" url.path="/orders/7" url.scheme="http" http.route="/orders/{id}" otel.name=GET /orders/{id} ulo.handler=OrdersController::order}: loading order order=7
2026-11-17T16:57:54.732613Z  INFO call{... url.path="/orders/7" ... http.route="/orders/{id}" ... http.response.status_code=200}: close time.busy=362µs time.idle=136µs
2026-11-17T16:57:54.742133Z  INFO call{... url.path="/orders/abc" ... http.route="/orders/{id}" ... http.response.status_code=400}: close time.busy=136µs time.idle=24.7µs
2026-11-17T16:57:54.749724Z  INFO call{... url.path="/nowhere" url.scheme="http" http.response.status_code=404}: close time.busy=32.5µs time.idle=15.4µs

An event inside the handler (loading order order=7) is printed with the same span prefix, so a handler's own log lines are joined to the request by the span fields.

Failure modes

The line is the span's, so it is wide. Every span field is printed on both the event lines and the close line. Filter the fields with a custom FormatFields, or switch to .json() and a collector that selects fields, when the line is too wide to read.

A path no route matched has no http.route. The /nowhere line carries url.path and the 404 but no route, so group a dashboard by http.route only for matched requests.

A request id is not on the line. The span has no request-id field. Log it from a handler or interceptor with tracing::info!(request_id = ..), which prints it inside the span prefix, or correlate by the trace context (Logging and tracing). The request id recipe sets the id.

The line is at INFO. The call span and its close event are INFO, so a subscriber filtered above INFO drops the access log.

The subscriber is the application's. Ulo installs none, so a second .init() panics. Install exactly one, early in main, before the app is built.

Reference

  • Logging and tracing: the call span, its attributes, and OpenTelemetry export.
  • Interceptors: where a per-request field is added from handler context.

Request IDs

Give every request an x-request-id and echo it on the response with the tower-http SetRequestIdLayer and PropagateRequestIdLayer.

Error reporting with Sentry

Report server faults to Sentry with the sentry-tracing error layer, fed by a global ErrorHandler that logs and passes every error on.

On this page

The codeWhat each seam doesFailure modesReference