pub struct SpanBuilder {
pub span: SpanRecord,
/* private fields */
}Fields§
§span: SpanRecordImplementations§
Source§impl SpanBuilder
impl SpanBuilder
pub fn new(kind: TraceWeftSpanKind, name: impl Into<String>) -> Self
pub fn provider(self, provider: impl Into<String>) -> Self
pub fn model(self, model: impl Into<String>) -> Self
pub fn prompt_version(self, version: impl Into<String>) -> Self
pub fn tool_name(self, tool: impl Into<String>) -> Self
Sourcepub fn input_ref<T: Serialize>(
self,
label: impl Into<String>,
value: &T,
) -> Self
pub fn input_ref<T: Serialize>( self, label: impl Into<String>, value: &T, ) -> Self
Capture a serializable input value under label when the span runs.
The value is converted to JSON immediately, but the blob is persisted
inside run / run_infallible so
the async blob store can be used without making every setter async.
When the active capture policy is MetadataOnly, no blob is written.
Sourcepub fn output_ref<T: Serialize>(
self,
label: impl Into<String>,
value: &T,
) -> Self
pub fn output_ref<T: Serialize>( self, label: impl Into<String>, value: &T, ) -> Self
Capture a serializable output value under label when the span runs.
This is for callers that already have or can cheaply precompute an output-like value. Use macros when you want successful function returns captured automatically.
Sourcepub fn input_blob_ref(self, blob_ref: BlobRef) -> Self
pub fn input_blob_ref(self, blob_ref: BlobRef) -> Self
Attach a pre-existing input blob reference without writing new content.
Sourcepub fn output_blob_ref(self, blob_ref: BlobRef) -> Self
pub fn output_blob_ref(self, blob_ref: BlobRef) -> Self
Attach a pre-existing output blob reference without writing new content.
pub fn token_usage(self, usage: TokenUsage) -> Self
pub fn cost(self, cost: CostEstimate) -> Self
pub fn cache_hit(self, hit: bool) -> Self
Sourcepub fn retrieval(
self,
query_hash: impl Into<String>,
doc_refs: Vec<BlobRef>,
) -> Self
pub fn retrieval( self, query_hash: impl Into<String>, doc_refs: Vec<BlobRef>, ) -> Self
Record a retrieval query hash and the documents it returned.
Sourcepub fn attribute(self, key: impl Into<String>, value: Value) -> Self
pub fn attribute(self, key: impl Into<String>, value: Value) -> Self
Insert a single free-form attribute.
Sourcepub fn attributes(self, attrs: HashMap<String, Value>) -> Self
pub fn attributes(self, attrs: HashMap<String, Value>) -> Self
Merge a map of free-form attributes into the span.
pub fn with_parent( self, trace_id: TraceId, run_id: RunId, parent_id: SpanId, ) -> Self
pub async fn wait_for_approval(self) -> Result<HitlResponse, String>
pub async fn run<F, Fut, T, E>(self, f: F) -> Result<T, E>
Sourcepub async fn run_infallible<F, Fut, T>(self, f: F) -> T
pub async fn run_infallible<F, Fut, T>(self, f: F) -> T
Like run but for closures that don’t return Result. The
span always completes with Ok status. Replay mocking (which is keyed on
deserializing a mocked value) applies only to run, not here.
Auto Trait Implementations§
impl Freeze for SpanBuilder
impl RefUnwindSafe for SpanBuilder
impl Send for SpanBuilder
impl Sync for SpanBuilder
impl Unpin for SpanBuilder
impl UnsafeUnpin for SpanBuilder
impl UnwindSafe for SpanBuilder
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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