pub struct BatchWriter { /* private fields */ }Expand description
Async batch writer that buffers telemetry items and flushes them to the underlying store in batches.
Items are added to an in-memory buffer on submit. A background
task periodically flushes the buffer to the store. Call flush()
for immediate persistence, or shutdown() to drain all remaining
items before process exit.
Implementations§
Source§impl BatchWriter
impl BatchWriter
Sourcepub fn new(store: Arc<dyn TraceStore>) -> Self
pub fn new(store: Arc<dyn TraceStore>) -> Self
Create a new batch writer with default configuration.
Starts a background flush task that runs until shutdown() is called.
Sourcepub fn with_config(
store: Arc<dyn TraceStore>,
batch_size: usize,
flush_interval_ms: u64,
) -> Self
pub fn with_config( store: Arc<dyn TraceStore>, batch_size: usize, flush_interval_ms: u64, ) -> Self
Create a batch writer with custom batch size and flush interval.
Sourcepub fn with_config_and_langfuse(
store: Arc<dyn TraceStore>,
langfuse: Option<LangfuseExporter>,
batch_size: usize,
flush_interval_ms: u64,
) -> Self
pub fn with_config_and_langfuse( store: Arc<dyn TraceStore>, langfuse: Option<LangfuseExporter>, batch_size: usize, flush_interval_ms: u64, ) -> Self
Create a batch writer with optional Langfuse cloud export.
Sourcepub async fn submit(&self, item: TelemetryItem) -> Result<(), StoreError>
pub async fn submit(&self, item: TelemetryItem) -> Result<(), StoreError>
Submit a telemetry item for async writing.
The item is added to an in-memory buffer. The buffer is flushed
to the store either when it reaches batch_size or on the next
periodic flush tick.
§Errors
Returns StoreError::Storage if the store write fails (only when
batch size is exceeded and an immediate flush is triggered).
Sourcepub async fn submit_trace(&self, trace: Trace) -> Result<(), StoreError>
pub async fn submit_trace(&self, trace: Trace) -> Result<(), StoreError>
Sourcepub async fn submit_observation(
&self,
observation: Observation,
) -> Result<(), StoreError>
pub async fn submit_observation( &self, observation: Observation, ) -> Result<(), StoreError>
Submit an observation for async writing.
§Errors
Returns StoreError::Storage if the store write fails.
Sourcepub async fn submit_session(&self, session: Session) -> Result<(), StoreError>
pub async fn submit_session(&self, session: Session) -> Result<(), StoreError>
Trait Implementations§
Source§impl Clone for BatchWriter
impl Clone for BatchWriter
Source§fn clone(&self) -> BatchWriter
fn clone(&self) -> BatchWriter
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for BatchWriter
impl !UnwindSafe for BatchWriter
impl Freeze for BatchWriter
impl Send for BatchWriter
impl Sync for BatchWriter
impl Unpin for BatchWriter
impl UnsafeUnpin for BatchWriter
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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