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§
Sourcefn client_socket_address(&self) -> Option<SocketAddr>
fn client_socket_address(&self) -> Option<SocketAddr>
Returns the client socket address, if available.
Sourcefn server_host(&self) -> Result<(String, u16), ServerHostError>
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.
Sourcefn matched_path(&self) -> Option<&MatchedPath>
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.
Sourcefn span_name(&self) -> String
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
Sourcefn user_agent(&self) -> Option<&str>
fn user_agent(&self) -> Option<&str>
Returns the user agent, if available.