pub struct LangfuseContext { /* private fields */ }Expand description
Thread-safe storage for Langfuse context attributes.
This context allows you to set attributes that will be automatically included in all spans created within the same context.
Implementations§
Source§impl LangfuseContext
impl LangfuseContext
Sourcepub fn set_session_id(&self, session_id: impl Into<String>) -> &Self
pub fn set_session_id(&self, session_id: impl Into<String>) -> &Self
Set the session ID for the current trace.
Sourcepub fn set_user_id(&self, user_id: impl Into<String>) -> &Self
pub fn set_user_id(&self, user_id: impl Into<String>) -> &Self
Set the user ID for the current trace.
Add tags to the current trace.
Tags are stored as a JSON array string.
Sourcepub fn set_metadata(&self, metadata: Value) -> &Self
pub fn set_metadata(&self, metadata: Value) -> &Self
Set metadata as JSON string.
Sourcepub fn set_attribute(
&self,
key: impl Into<String>,
value: impl Into<String>,
) -> &Self
pub fn set_attribute( &self, key: impl Into<String>, value: impl Into<String>, ) -> &Self
Set a custom attribute.
Sourcepub fn set_trace_name(&self, name: impl Into<String>) -> &Self
pub fn set_trace_name(&self, name: impl Into<String>) -> &Self
Set the trace name.
Sourcepub fn get_attributes(&self) -> Vec<KeyValue>
pub fn get_attributes(&self) -> Vec<KeyValue>
Get all current attributes as key-value pairs.
Sourcepub fn has_attribute(&self, key: &str) -> bool
pub fn has_attribute(&self, key: &str) -> bool
Check if a specific attribute is set.
Sourcepub fn get_attribute(&self, key: &str) -> Option<String>
pub fn get_attribute(&self, key: &str) -> Option<String>
Get a specific attribute value.
Trait Implementations§
Source§impl Clone for LangfuseContext
impl Clone for LangfuseContext
Source§fn clone(&self) -> LangfuseContext
fn clone(&self) -> LangfuseContext
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for LangfuseContext
impl RefUnwindSafe for LangfuseContext
impl Send for LangfuseContext
impl Sync for LangfuseContext
impl Unpin for LangfuseContext
impl UnwindSafe for LangfuseContext
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