1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
use ServerErrorsAsFailures;
use SharedClassifier;
use ;
/// Span maker that creates an `http_request` tracing span for each request.
///
/// Includes a `tenant_id` field (initially empty) so that the tenant
/// middleware can record it via `span.record("tenant_id", ...)` after
/// resolving the tenant.
;
/// Returns a tracing layer configured for HTTP request/response lifecycle logging.
///
/// The span name is `http_request` and the initial fields are `method`,
/// `uri`, `version`, and `tenant_id` (empty — filled in by the tenant
/// middleware via [`tracing::Span::record`] after tenant resolution).
/// Any middleware that needs to record a span field must add it to
/// [`ModoMakeSpan`] first; fields not pre-declared are dropped by
/// `tracing`.
///
/// # Layer ordering
///
/// Install `tracing()` **outermost** (the last `.layer(...)` call in your
/// chain) so every inbound request — including those rejected by
/// [`csrf`](super::csrf) / [`rate_limit`](super::rate_limit) — is
/// observed inside the span.
///
/// # Example
///
/// ```rust,no_run
/// use axum::{Router, routing::get};
/// use modo::middleware::tracing;
///
/// let app: Router = Router::new()
/// .route("/", get(|| async { "ok" }))
/// .layer(tracing());
/// ```