pub struct LangfuseState<S = BoxedSpan> { /* private fields */ }Expand description
State managed by the Langfuse interceptor across the request lifecycle.
This state is passed through the interceptor hooks to maintain span information without requiring global state.
Uses Mutex for interior mutability to ensure thread-safety in async contexts.
The generic type S is the Span type from the tracer.
Trait Implementations§
Source§impl<S> Default for LangfuseState<S>
impl<S> Default for LangfuseState<S>
Source§impl<T: Tracer + Send + Sync> Interceptor<LangfuseState<<T as Tracer>::Span>> for Arc<LangfuseInterceptor<T>>
impl<T: Tracer + Send + Sync> Interceptor<LangfuseState<<T as Tracer>::Span>> for Arc<LangfuseInterceptor<T>>
Source§fn before_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 mut BeforeRequestContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn before_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 mut BeforeRequestContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called before a request is sent. Read more
Source§fn after_response<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 AfterResponseContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn after_response<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 AfterResponseContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called after a successful non-streaming response is received.
Source§fn on_stream_chunk<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 StreamChunkContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_stream_chunk<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 StreamChunkContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called for each chunk in a streaming response.
Source§fn on_stream_end<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 StreamEndContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_stream_end<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 StreamEndContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when a streaming response completes successfully.
Source§fn on_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 ErrorContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 ErrorContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when an error occurs at any stage. Read more
Source§impl<T: Tracer + Send + Sync> Interceptor<LangfuseState<<T as Tracer>::Span>> for LangfuseInterceptor<T>
impl<T: Tracer + Send + Sync> Interceptor<LangfuseState<<T as Tracer>::Span>> for LangfuseInterceptor<T>
Source§fn before_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 mut BeforeRequestContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn before_request<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 mut BeforeRequestContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called before a request is sent. Read more
Source§fn after_response<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 AfterResponseContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn after_response<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 AfterResponseContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called after a successful non-streaming response is received.
Source§fn on_stream_chunk<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 StreamChunkContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_stream_chunk<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_ctx: &'life1 StreamChunkContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called for each chunk in a streaming response.
Source§fn on_stream_end<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 StreamEndContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_stream_end<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 StreamEndContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when a streaming response completes successfully.
Source§fn on_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 ErrorContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn on_error<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
ctx: &'life1 ErrorContext<'life2, LangfuseState<T::Span>>,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called when an error occurs at any stage. Read more
Auto Trait Implementations§
impl<S = BoxedSpan> !Freeze for LangfuseState<S>
impl<S> RefUnwindSafe for LangfuseState<S>
impl<S> Send for LangfuseState<S>where
S: Send,
impl<S> Sync for LangfuseState<S>where
S: Send,
impl<S> Unpin for LangfuseState<S>where
S: Unpin,
impl<S> UnwindSafe for LangfuseState<S>
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
Mutably borrows from an owned value. Read more