Skip to main content

GraphTrace

Struct GraphTrace 

Source
pub struct GraphTrace { /* private fields */ }
Expand description

Opinionated tracing helpers to build a Graph-style hierarchy in LangSmith:

  • Root run named Graph (RunType::Chain)
  • Step runs under root (e.g. chatbot, should_continue, tools)
  • Nested runs under steps (e.g. ChatOpenAI, tool runs)

This is intentionally generic: inputs/outputs are serde_json::Value so any app can provide LangSmith-compatible payloads such as { \"messages\": [...] }.

Implementations§

Source§

impl GraphTrace

Source

pub async fn start_root( inputs: Value, thread_id: Option<String>, ) -> Result<Self>

Starts the root Graph run (name: Graph, type: Chain) and POSTs it.

Source

pub fn root_scope(&self) -> &RunScope

Source

pub fn root_tracer(&self) -> &Tracer

Source

pub async fn start_node_iteration( &self, node_name: &str, inputs: Value, ) -> Result<RunScope>

Starts a top-level step/node under the root run (POSTs it) and returns the scope. Use this for nodes like “chatbot”, “tools”, etc. that may contain nested runs.

Source

pub async fn trace_llm_call( &self, parent_node: &RunScope, llm_name: &str, inputs: Value, outputs: Value, model_name: Option<&str>, ) -> Result<()>

Traces an LLM call within a parent node (e.g., within “chatbot”). llm_name is typically “ChatOpenAI” or similar. model_name is optional (e.g., “gpt-4o-mini”) and will be added to inputs if provided.

Source

pub async fn trace_decision( &self, parent_node: &RunScope, decision_name: &str, inputs: Value, outputs: Value, ) -> Result<()>

Traces a routing/decision step (e.g., “should_continue”).

Source

pub async fn trace_tool_call( &self, parent_node: &RunScope, tool_name: &str, inputs: Value, outputs: Value, ) -> Result<()>

Traces a tool call within a parent node (e.g., within “tools”). tool_name should be the actual tool name (e.g., “calculator”).

Source

pub async fn end_root(self, outputs: Value) -> Result<()>

Ends the root run with the provided outputs (PATCH). Consumes self.

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