Skip to main content

SpanBuilder

Struct SpanBuilder 

Source
pub struct SpanBuilder {
    pub span: SpanRecord,
    /* private fields */
}

Fields§

§span: SpanRecord

Implementations§

Source§

impl SpanBuilder

Source

pub fn new(kind: TraceWeftSpanKind, name: impl Into<String>) -> Self

Source

pub fn provider(self, provider: impl Into<String>) -> Self

Source

pub fn model(self, model: impl Into<String>) -> Self

Source

pub fn prompt_version(self, version: impl Into<String>) -> Self

Source

pub fn tool_name(self, tool: impl Into<String>) -> Self

Source

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.

Source

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.

Source

pub fn input_blob_ref(self, blob_ref: BlobRef) -> Self

Attach a pre-existing input blob reference without writing new content.

Source

pub fn output_blob_ref(self, blob_ref: BlobRef) -> Self

Attach a pre-existing output blob reference without writing new content.

Source

pub fn token_usage(self, usage: TokenUsage) -> Self

Source

pub fn cost(self, cost: CostEstimate) -> Self

Source

pub fn cache_hit(self, hit: bool) -> Self

Source

pub fn retrieval( self, query_hash: impl Into<String>, doc_refs: Vec<BlobRef>, ) -> Self

Record a retrieval query hash and the documents it returned.

Source

pub fn attribute(self, key: impl Into<String>, value: Value) -> Self

Insert a single free-form attribute.

Source

pub fn attributes(self, attrs: HashMap<String, Value>) -> Self

Merge a map of free-form attributes into the span.

Source

pub fn with_parent( self, trace_id: TraceId, run_id: RunId, parent_id: SpanId, ) -> Self

Source

pub async fn wait_for_approval(self) -> Result<HitlResponse, String>

Source

pub async fn run<F, Fut, T, E>(self, f: F) -> Result<T, E>
where F: FnOnce() -> Fut, Fut: Future<Output = Result<T, E>>, E: Debug + Display + 'static, T: DeserializeOwned,

Source

pub async fn run_infallible<F, Fut, T>(self, f: F) -> T
where F: FnOnce() -> Fut, Fut: Future<Output = 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§

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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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