make_request_spanner

Macro make_request_spanner 

Source
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.method
  • http.url
  • http.request_id - Inherited from request ‘X-Request-Id’ or random uuid
  • http.user_agent - Only populated if user agent header is present
  • http.version
  • http.headers - Optional. Populated if more than 1 header specified via layer config
  • protocol - Either http or grpc depending on content-type
  • http.client.ip - Optionally added if IP extractor is specified via layer config
  • http.status_code - Semantics of this code depends on protocol
  • error.message - Populated with Display content of the error, returned by underlying service, after processing request.

§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("http.url", "I can override span field");