stackable_telemetry::instrumentation::axum

Trait RequestExt

Source
pub trait RequestExt {
    // Required methods
    fn client_socket_address(&self) -> Option<SocketAddr>;
    fn server_host(&self) -> Result<(String, u16), ServerHostError>;
    fn matched_path(&self) -> Option<&MatchedPath>;
    fn span_name(&self) -> String;
    fn user_agent(&self) -> Option<&str>;
}
Expand description

This trait provides various helper functions to extract data from a HTTP [Request].

Required Methods§

Source

fn client_socket_address(&self) -> Option<SocketAddr>

Returns the client socket address, if available.

Source

fn server_host(&self) -> Result<(String, u16), ServerHostError>

Returns the server host, if available.

§Value Selection Strategy

The following value selection strategy is taken verbatim from this section of the HTTP span semantic conventions:

HTTP server instrumentations SHOULD do the best effort when populating server.address and server.port attributes and SHOULD determine them by using the first of the following that applies:

  • The original host which may be passed by the reverse proxy in the Forwarded#host, X-Forwarded-Host, or a similar header.
  • The :authority pseudo-header in case of HTTP/2 or HTTP/3
  • The Host header.
Source

fn matched_path(&self) -> Option<&MatchedPath>

Returns the matched path, like /object/:object_id/tags.

The returned path has low cardinality. It will never contain any path or query parameter. This behaviour is suggested by the conventions specification.

Source

fn span_name(&self) -> String

Returns the span name.

The format is either {method} {http.route} or {method} if http.route is not available. Examples are:

  • GET /object/:object_id/tags
  • PUT /upload/:file_id
  • POST /convert
  • OPTIONS
Source

fn user_agent(&self) -> Option<&str>

Returns the user agent, if available.

Implementations on Foreign Types§

Source§

impl RequestExt for Request

Implementors§