pub struct TraceContext {
pub run: RunScope,
pub step: Option<StepScope>,
pub tool_call: Option<ToolCallScope>,
pub policy_decision: Option<PolicyDecisionScope>,
pub budget: Option<BudgetScope>,
pub seed: Option<i64>,
pub baggage: Vec<(String, String)>,
/* private fields */
}Expand description
Trace context tying together run, step, tool, and policy scopes.
Fields§
§run: RunScope§step: Option<StepScope>§tool_call: Option<ToolCallScope>§policy_decision: Option<PolicyDecisionScope>§budget: Option<BudgetScope>§seed: Option<i64>§baggage: Vec<(String, String)>Implementations§
Source§impl TraceContext
impl TraceContext
Sourcepub fn with_trace_id(self, trace_id: TraceId) -> Self
pub fn with_trace_id(self, trace_id: TraceId) -> Self
Override the generated trace identifier (used for deterministic trace IDs).
Sourcepub fn with_span_id(self, span_id: SpanId) -> Self
pub fn with_span_id(self, span_id: SpanId) -> Self
Override the generated span identifier.
Sourcepub fn with_parent_span_id(
self,
parent_span_id: impl Into<Option<SpanId>>,
) -> Self
pub fn with_parent_span_id( self, parent_span_id: impl Into<Option<SpanId>>, ) -> Self
Set an explicit parent span identifier.
Sourcepub fn from_parent(
run: RunScope,
trace_id: TraceId,
parent_span_id: SpanId,
) -> Self
pub fn from_parent( run: RunScope, trace_id: TraceId, parent_span_id: SpanId, ) -> Self
Create a trace context from an existing trace_id/span_id pair, typically
when continuing a trace injected by an upstream caller.
Sourcepub fn with_seed(self, seed: impl Into<Option<i64>>) -> Self
pub fn with_seed(self, seed: impl Into<Option<i64>>) -> Self
Attach a deterministic seed to the trace.
Sourcepub fn with_trace_flags(self, flags: TraceFlags) -> Self
pub fn with_trace_flags(self, flags: TraceFlags) -> Self
Override the trace flags (e.g., when sampling is disabled).
Sourcepub fn with_tracestate(self, tracestate: impl Into<Option<String>>) -> Self
pub fn with_tracestate(self, tracestate: impl Into<Option<String>>) -> Self
Set an explicit W3C tracestate header value.
Sourcepub fn from_w3c(
run: RunScope,
traceparent: &str,
tracestate: Option<&str>,
baggage: Option<&str>,
) -> Result<Self>
pub fn from_w3c( run: RunScope, traceparent: &str, tracestate: Option<&str>, baggage: Option<&str>, ) -> Result<Self>
Construct a trace context from W3C headers captured on ingress.
Sourcepub fn with_baggage<I, K, V>(self, baggage: I) -> Self
pub fn with_baggage<I, K, V>(self, baggage: I) -> Self
Replace baggage entries (for example to propagate budgets or experiment IDs).
Sourcepub fn with_budget(self, budget: BudgetScope) -> Self
pub fn with_budget(self, budget: BudgetScope) -> Self
Attach budget scope metadata.
Sourcepub fn child_step(&self, scope: StepScope) -> Self
pub fn child_step(&self, scope: StepScope) -> Self
Generate a child span context representing a step.
Sourcepub fn child_tool_call(&self, scope: ToolCallScope) -> Self
pub fn child_tool_call(&self, scope: ToolCallScope) -> Self
Generate a child span context representing a tool call.
Sourcepub fn child_policy_decision(&self, scope: PolicyDecisionScope) -> Self
pub fn child_policy_decision(&self, scope: PolicyDecisionScope) -> Self
Generate a child span context representing a policy decision.
Sourcepub fn trace_flags(&self) -> TraceFlags
pub fn trace_flags(&self) -> TraceFlags
Trace flags used when constructing spans.
Sourcepub fn parent_span_id(&self) -> Option<SpanId>
pub fn parent_span_id(&self) -> Option<SpanId>
Parent span identifier, if any.
Sourcepub fn traceparent(&self) -> String
pub fn traceparent(&self) -> String
Compute the W3C traceparent header value.
Sourcepub fn tracestate(&self) -> Option<String>
pub fn tracestate(&self) -> Option<String>
Return the stored W3C tracestate header value, if any.
Sourcepub fn baggage_header(&self) -> Option<String>
pub fn baggage_header(&self) -> Option<String>
Return the formatted W3C baggage header, if any entries are present.
Sourcepub fn w3c_headers(&self) -> Vec<(String, String)>
pub fn w3c_headers(&self) -> Vec<(String, String)>
Produce the standard set of W3C headers (traceparent, tracestate, baggage).
Sourcepub fn as_parent_context(&self) -> OtelContext
pub fn as_parent_context(&self) -> OtelContext
Build an OpenTelemetry context representing this trace (as a remote parent).
Sourcepub fn from_span_context(
run: RunScope,
step: Option<StepScope>,
tool_call: Option<ToolCallScope>,
policy_decision: Option<PolicyDecisionScope>,
budget: Option<BudgetScope>,
parent_span_id: Option<SpanId>,
span_context: SpanContext,
seed: Option<i64>,
baggage: Vec<(String, String)>,
) -> Self
pub fn from_span_context( run: RunScope, step: Option<StepScope>, tool_call: Option<ToolCallScope>, policy_decision: Option<PolicyDecisionScope>, budget: Option<BudgetScope>, parent_span_id: Option<SpanId>, span_context: SpanContext, seed: Option<i64>, baggage: Vec<(String, String)>, ) -> Self
Construct a trace context from a recorded span (e.g., after creating a tracing span).
Sourcepub fn attributes(&self) -> Vec<KeyValue>
pub fn attributes(&self) -> Vec<KeyValue>
Convert the trace context into OpenTelemetry attributes using the
fleetforge.* namespace.
Trait Implementations§
Source§impl Clone for TraceContext
impl Clone for TraceContext
Source§fn clone(&self) -> TraceContext
fn clone(&self) -> TraceContext
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TraceContext
impl Debug for TraceContext
Auto Trait Implementations§
impl Freeze for TraceContext
impl RefUnwindSafe for TraceContext
impl Send for TraceContext
impl Sync for TraceContext
impl Unpin for TraceContext
impl UnwindSafe for TraceContext
Blanket Implementations§
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.