pub trait HttpEvent {
// Required methods
fn method(&self) -> Method;
fn target(&self) -> String;
fn headers(&self) -> &HeaderMap;
fn route(&self) -> String;
fn full_url(&self) -> String;
fn client_address(&self) -> String;
fn query_string(&self) -> String;
}Expand description
A trait to extract HTTP information from Lambda event payloads.
This trait should be implemented for various Lambda event types that represent HTTP requests, such as API Gateway events or Application Load Balancer events.
§Examples
use http::{HeaderMap, Method};
use lambda_otel_utils::http_otel_layer::HttpEvent;
struct CustomHttpEvent {
method: Method,
path: String,
headers: HeaderMap,
}
impl HttpEvent for CustomHttpEvent {
fn method(&self) -> Method {
self.method.clone()
}
fn target(&self) -> String {
self.path.clone()
}
fn headers(&self) -> &HeaderMap {
&self.headers
}
fn route(&self) -> String {
self.path.clone()
}
fn query_string(&self) -> String {
String::new() // No query string in this example
}
fn full_url(&self) -> String {
self.path.clone() // No query parameters in this example
}
fn client_address(&self) -> String {
String::new() // No client address in this example
}
}Required Methods§
fn method(&self) -> Method
fn target(&self) -> String
fn headers(&self) -> &HeaderMap
fn route(&self) -> String
fn full_url(&self) -> String
fn client_address(&self) -> String
fn query_string(&self) -> String
Implementations on Foreign Types§
Source§impl HttpEvent for AlbTargetGroupRequest
impl HttpEvent for AlbTargetGroupRequest
Extracts OpenTelemetry attributes from Application Load Balancer Target Group requests including:
- HTTP method from http_method field
- Target path from path field
- Headers from headers field
- Route from path field
- Query string parameters from query_string_parameters map
- Full URL construction combining path and query parameters
- Client IP address from x-forwarded-for header
Source§impl HttpEvent for ApiGatewayProxyRequest
impl HttpEvent for ApiGatewayProxyRequest
Implementation of HttpEvent for API Gateway REST API proxy requests.
This implementation extracts OpenTelemetry-compatible HTTP attributes from API Gateway REST API proxy requests. It handles:
- HTTP method
- Target path
- Headers
- Route/resource path
- Query string parameters
- Full URL construction
- Client IP address
Source§impl HttpEvent for ApiGatewayV2httpRequest
impl HttpEvent for ApiGatewayV2httpRequest
Implementation of HttpEvent for API Gateway V2 HTTP requests.
Extracts OpenTelemetry attributes from API Gateway V2 HTTP requests including:
- HTTP method
- Target path from raw_path
- Headers
- Route key or raw path as route
- Raw query string parameters
- Full URL construction
- Client IP address from source_ip