macro_rules! make_request_spanner {
($fn:ident($name:literal, $level:expr)) => { ... };
($fn:ident($name:literal, $level:expr, $($fields:tt)*)) => { ... };
}Expand description
Declares fn function compatible with MakeSpan using provided parameters
§Span fields
Following fields are declared when span is created:
http.request.methodurl.pathurl.queryurl.schemehttp.request_id- Inherited from request ‘X-Request-Id’ or random uuiduser_agent.original- Only populated if user agent header is presenthttp.headers- Optional. Populated if more than 1 header specified via layer confignetwork.protocol.name- Eitherhttporgrpcdepending oncontent-typenetwork.protocol.version- Set to HTTP version in case of plainhttpprotocol.client.address- Optionally added if IP extractor is specified via layer confighttp.response.status_code- Semantics of this code depends onprotocolerror.type- Populated withcore::any::type_namevalue of error type used by the service.error.message- Populated withDisplaycontent of the error, returned by underlying service, after processing request.
Loosely follows https://opentelemetry.io/docs/specs/semconv/http/http-spans/#http-server
§Additional fields
Additional fields can be declared by passing extra arguments after level in the same way as you would pass it to tracing::span! macro
Note that you need to use tracing::field::Empty if you want to add value later
§Usage
use tower_http_tracing::make_request_spanner;
make_request_spanner!(make_my_request_span("my_request", tracing::Level::INFO));
make_request_spanner!(make_my_service_request_span("my_request", tracing::Level::INFO, service_name = "<your name>"));
let span = make_my_request_span();
span.record("url.path", "I can override span field");