pub struct DebugState {Show 13 fields
pub enabled: bool,
pub sandbox_enabled: bool,
pub trigger_header: String,
pub trace_all: bool,
pub capture_bodies: bool,
pub max_body_bytes: usize,
pub max_traces: usize,
pub max_steps: usize,
pub sandbox_timeout_seconds: u64,
redaction: RedactionPolicy,
traces: Mutex<VecDeque<Arc<Trace>>>,
seq: AtomicU64,
evicted: AtomicU64,
}Expand description
Resolved debug settings plus the trace buffer.
Every field is immutable after construction — system.yaml is not
hot-reloaded, so debug mode cannot be switched on in a running process.
That is deliberate: it means a compromised Admin API credential cannot
start capturing request contexts.
Fields§
§enabled: bool§sandbox_enabled: bool§trigger_header: StringLowercased, because GatewayRequest stores header names as hyper
normalised them.
trace_all: bool§capture_bodies: bool§max_body_bytes: usize§max_traces: usize§max_steps: usize§sandbox_timeout_seconds: u64§redaction: RedactionPolicy§traces: Mutex<VecDeque<Arc<Trace>>>§seq: AtomicU64§evicted: AtomicU64Traces dropped to keep the buffer at max_traces.
Kept so a caller can tell an empty result apart from a rotated-out one. Without it, filtering for something that has just aged out is indistinguishable from filtering for something that never happened – which has already produced one confident, wrong “the filter is broken” diagnosis.
Implementations§
Source§impl DebugState
impl DebugState
Sourcepub fn new(cfg: &DebugConfig) -> Self
pub fn new(cfg: &DebugConfig) -> Self
Builds the runtime state from config.
Sourcepub fn capture_options(&self) -> CaptureOptions
pub fn capture_options(&self) -> CaptureOptions
Capture knobs for a snapshot.
Sourcepub fn should_trace(&self, headers: &HashMap<String, Vec<String>>) -> bool
pub fn should_trace(&self, headers: &HashMap<String, Vec<String>>) -> bool
Whether this request should be traced.
The whole cost on an untraced request: one HashMap::get against the
already-built header map, and only when debug is enabled at all.
Sourcepub fn header_opt_in(&self, headers: &HashMap<String, Vec<String>>) -> bool
pub fn header_opt_in(&self, headers: &HashMap<String, Vec<String>>) -> bool
Whether the request explicitly asked to be traced via the trigger
header, as opposed to being swept up by trace_all.
The x-featherbit-trace-id response header is returned only in this
case: the id is a reply to a caller who opted in. Under trace_all the
traffic is anonymous, so stamping every response with a debug id would
leak it to clients that never asked — those traces are found in the
panel/list instead.
Sourcepub fn record(&self, trace: Trace)
pub fn record(&self, trace: Trace)
Stores a trace, evicting the oldest entries beyond max_traces.
Sourcepub fn retention(&self) -> Retention
pub fn retention(&self) -> Retention
What the buffer holds and what it has discarded.
Returned alongside every trace listing so an empty result is
self-explanatory: with truncated set and an oldest_seq to compare
against, “no traces matched” and “the matches aged out” stop looking
the same.
Sourcepub fn list(&self) -> Vec<TraceSummary>
pub fn list(&self) -> Vec<TraceSummary>
Summaries, newest first.
Auto Trait Implementations§
impl !Freeze for DebugState
impl RefUnwindSafe for DebugState
impl Send for DebugState
impl Sync for DebugState
impl Unpin for DebugState
impl UnsafeUnpin for DebugState
impl UnwindSafe for DebugState
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more