pub struct RequestContext {
pub telemetry: TelemetryHandle,
pub deadline: Option<Instant>,
pub trace_id: Option<Arc<[u8]>>,
pub baggage: Option<Arc<[u8]>>,
pub pipe_label: Option<Arc<[u8]>>,
pub upstream_label: Option<Arc<[u8]>>,
pub extra_labels: Labels,
pub path_params: BTreeMap<String, String>,
pub cancel: Signal,
pub capture: Option<Arc<dyn CaptureContext>>,
pub local_upgrade_ticket: Option<u64>,
pub peer: Option<PeerInfo>,
}Fields§
§telemetry: TelemetryHandle§deadline: Option<Instant>Optional request deadline, on the bound timer driver’s clock. Build it
from proxima_core::time::now() so the origin agrees with the reader’s
(src/load.rs races dispatch against it).
trace_id: Option<Arc<[u8]>>trace identifier — typically W3C traceparent ASCII bytes.
Arc<[u8]> so per-request clones are refcount bumps. Populated by
adopt_trace_context; proxima-pipe
carries only this byte form — the typed trace/span identifier parse +
generate logic lives in proxima_telemetry::propagation.
baggage: Option<Arc<[u8]>>W3C baggage header bytes lifted off the inbound request, re-stamped
onto the outbound request so application context survives the hop.
Arc<[u8]> so per-request clones are refcount bumps. None when the
inbound request carried no (valid) baggage.
pipe_label: Option<Arc<[u8]>>§upstream_label: Option<Arc<[u8]>>§extra_labels: Labels§path_params: BTreeMap<String, String>path-pattern parameters extracted by the mount router. {id} in the
mount path becomes path_params["id"]. empty when the mount has no
params or the request was not routed through one.
cancel: Signalper-request cancellation token. Only available under std (requires tokio).
cancelled when the listener observes connection close, deadline expiry,
or operator-initiated shutdown. child Pipes should call .child()
for sub-operations they need to cancel independently.
capture: Option<Arc<dyn CaptureContext>>per-call sidecar a wrapping RecordUpstream installs when the chain
is being recorded. None when no recording is active — Pipes
must handle that case explicitly to avoid silently dropping data.
local_upgrade_ticket: Option<u64>io_uring upgrade ticket. The io_uring listener mints this per
request before dispatching; Pipe authors use it with
crate::pipe::upgrade::local_slots::install to register a
LocalUpgradeHandler that runs against the !Send socket
after the listener writes the upgrade response head. None on
the default (tokio) listener path where the Send-bound
Response.upgrade field is the correct seam instead.
peer: Option<PeerInfo>Peer address for this request. When PROXY protocol is active
this is the original client (not the load balancer); without
PROXY it’s the raw socket peer. None on core paths
that don’t carry an address (purely in-process Pipe calls,
for example).
Implementations§
Source§impl RequestContext
impl RequestContext
pub fn with_telemetry(self, telemetry: TelemetryHandle) -> Self
pub fn with_cancel(self, cancel: Signal) -> Self
Sourcepub fn child_signal(&self) -> Signal
pub fn child_signal(&self) -> Signal
Derive a child scope from this context’s cancel. Firing the
child does not affect the parent; firing the parent fires
every descendant.
pub fn with_pipe_label(self, label: impl AsRef<[u8]>) -> Self
pub fn with_upstream_label(self, label: impl AsRef<[u8]>) -> Self
pub fn with_peer(self, peer: PeerInfo) -> Self
Sourcepub fn adopt_trace_context(
&mut self,
trace_id: Option<Bytes>,
baggage: Option<Bytes>,
)
pub fn adopt_trace_context( &mut self, trace_id: Option<Bytes>, baggage: Option<Bytes>, )
Adopt the byte-form trace id + baggage payload a listener already
established at ingress via
proxima_telemetry::propagation::establish_trace_context. Proxima
acts as a real hop: that establishment step adopts the inbound trace
id (or originates a fresh trace id + span id when none is present)
and PRESERVES the inbound span id rather than discarding it — a span
later opened with parent = self.traceparent() therefore records the
real inbound span as its parent_span_id, so the literal parent
chain crosses the wire hop instead of only the shared trace_id.
trace_id replaces the existing value whenever present (the
establishment step always produces one under std); baggage only
overwrites when present, so an already-set baggage value is not
clobbered by a re-adoption carrying no inbound baggage header.
proxima-pipe carries no trace identifier type (no header parsing, no
generation) — that logic lives in the telemetry layer’s own
propagation module, which already depends on this crate for
HeaderList. This method is the seam that keeps the dependency
one-directional: the listener (already depending on that layer)
does the establishment and hands this crate only the resulting bytes.
Sourcepub fn traceparent(&self) -> Option<&[u8]>
pub fn traceparent(&self) -> Option<&[u8]>
The raw W3C traceparent bytes this request carries (this hop’s own
span, restamped by
adopt_trace_context) — ready to hand
straight to #[proxima::instrument(parent = ...)] or
Recorder::span_from_traceparent. None before adopt_trace_context
runs, or on a request that predates trace context. This is the
boundary seam: a handler passes request.context.traceparent() so its
span continues the inbound trace instead of opening a fresh root —
proxima has no ambient “current span” for it to inherit otherwise.
Sourcepub fn inject_propagation(&self, headers: &mut HeaderList)
pub fn inject_propagation(&self, headers: &mut HeaderList)
Stamp the carried traceparent + baggage onto outbound headers.
Called at upstream egress. insert_if_absent semantics — a value the
caller already set wins.