Skip to main content

RequestContext

Struct RequestContext 

Source
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: Signal

per-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

Source

pub fn with_telemetry(self, telemetry: TelemetryHandle) -> Self

Source

pub fn with_cancel(self, cancel: Signal) -> Self

Source

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.

Source

pub fn with_pipe_label(self, label: impl AsRef<[u8]>) -> Self

Source

pub fn with_upstream_label(self, label: impl AsRef<[u8]>) -> Self

Source

pub fn with_peer(self, peer: PeerInfo) -> Self

Source

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.

Source

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.

Source

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.

Source

pub fn metric_labels(&self, additional: &[(&str, &str)]) -> Labels

Trait Implementations§

Source§

impl Clone for RequestContext

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RequestContext

Source§

fn fmt(&self, formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for RequestContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more