Skip to main content

BatchSpanExporter

Struct BatchSpanExporter 

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

批量 Span 导出器(内存模拟)。

收集 span 到队列,达到批次大小或导出间隔时批量导出。 实际实现中会通过 OTLP/HTTP 发送到 Collector。

Implementations§

Source§

impl BatchSpanExporter

Source

pub fn new(config: BatchConfig) -> Self

创建批量导出器

Source

pub fn enqueue(&self, span: Span)

将 span 加入导出队列

Source

pub fn flush_batch(&self) -> usize

尝试导出一批 span。

当队列长度 >= max_batch_size 时导出整批,否则不导出。 返回导出的 span 数量。

Source

pub fn flush_all(&self) -> usize

强制导出所有排队中的 span,不论批次大小。

Source

pub fn exported_batch_count(&self) -> usize

获取已导出的批次数

Source

pub fn exported_span_count(&self) -> usize

获取已导出的 span 总数

Source

pub fn queue_len(&self) -> usize

获取当前队列长度

Source

pub fn dropped_count(&self) -> u64

获取被丢弃的 span 数量

Source

pub fn clear(&self)

清空所有状态(队列与已导出记录)

Source

pub fn config(&self) -> &BatchConfig

获取配置引用

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