Module instrumentation

Source
Expand description

Provides InstrumentOperation and a variety of helpers structures for dealing with sensitive data. Together they allow compliance with the sensitive trait.

§Example

let request = Request::get("http://localhost/a/b/c/d?bar=hidden")
    .header("header-name-a", "hidden")
    .body(())
    .unwrap();

let request_fmt = RequestFmt::new()
    .header(|name| HeaderMarker {
       value: name == "header-name-a",
       key_suffix: None,
    })
    .query(|name| QueryMarker { key: false, value: name == "bar" })
    .label(|index| index % 2 == 0, None);
let response_fmt = ResponseFmt::new()
    .header(|name| {
        if name.as_str().starts_with("prefix-") {
            HeaderMarker {
                value: true,
                key_suffix: Some("prefix-".len()),
            }
        } else {
            HeaderMarker {
                value: name == "header-name-b",
                key_suffix: None,
            }
        }
    })
    .status_code();
let mut service = InstrumentOperation::new(service, ID)
    .request_fmt(request_fmt)
    .response_fmt(response_fmt);

let _ = service.call(request).await.unwrap();

Modules§

sensitivity
The combination of HTTP binding traits and the sensitive trait require us to redact portions of the HTTP requests/responses during logging.

Structs§

InstrumentOperation
A middleware [Service] responsible for:
InstrumentPlugin
A Plugin which applies InstrumentOperation to every operation.
InstrumentedFuture
An instrumented Future responsible for logging the response status code and headers.
MakeIdentity
A blanket, identity, MakeFmt implementation. Applies no changes to the Display/Debug implementation.

Traits§

InstrumentExt
An extension trait for applying InstrumentPlugin.
MakeDebug
Identical to MakeFmt but with a Debug bound on the associated type.
MakeDisplay
Identical to MakeFmt but with a Display bound on the associated type.
MakeFmt
A standard interface for taking some component of the HTTP request/response and transforming it into new struct which enjoys Debug or Display. This allows for polymorphism over formatting approaches.