Skip to main content

Module trace

Module trace 

Source
Expand description

Trace records and context snapshots.

A Trace is one policy execution — a live request or a sandbox run — recorded as an initial ContextSnapshot plus one NodeStep per node the engine walked.

§Why one snapshot per step, not before/after pairs

The Context flows strictly linearly: every plugin takes it by value and hands it back in both the Ok and Err arms of PluginResult, so before(step N) == after(step N - 1) and before(step 0) == Trace::initial are guaranteed by the plugin contract itself. Storing explicit pairs would double memory for exactly zero information.

The “what did this plugin change” view is therefore derived, not stored: see crate::debug::diff, which is computed at read time so the traced request path stays cheap.

Structs§

BodyCapture
How a captured body was handled.
CaptureOptions
Knobs for capturing a snapshot, resolved from DebugConfig.
ContextSnapshot
A redacted point-in-time view of the whole Context.
NodeStep
One node execution.
PreviousBodies
The bodies seen at the previous step, used to avoid storing an unchanged body once per node. Cloning Bytes is a refcount bump, not a copy.
RedactionPolicy
Case-insensitive denylists used when capturing a snapshot.
RequestSnapshot
Redacted view of Context.request.
ResponseSnapshot
Redacted view of Context.response.
Trace
One complete policy execution.

Enums§

EdgeKind
Which edge the engine followed after a node — including the cases where there was none, which is what makes an unwired error port visible.
StepOutcome
Whether a node returned success or routed through its error port.
TraceSource
Whether a trace came from live traffic or a sandbox run.

Constants§

DEFAULT_REDACT_HEADERS 🔒
Header names always redacted, regardless of configuration.
DEFAULT_REDACT_MESSAGE_SUBSTRINGS 🔒
Substrings that mark a context.message key as secret-bearing.
DEFAULT_REDACT_QUERY 🔒
Query parameters always redacted. OAuth/OIDC put codes and tokens in the query string, so omitting these would leak on every openid-connect trace.
REDACTED
Placeholder substituted for any value the redaction policy matches.

Functions§

capture_body 🔒
Records the body length always, and the text only when capture is on and the bytes differ from the previous step.
redact_map 🔒
Redacts a header/query map into a deterministic BTreeMap, preserving the arity of multi-valued entries so the shape of the request is still visible.