pub struct StatsExporter<Cap: HttpClientCapability + SleepCapability + MaybeSend + Sync + 'static, Con: FlushableConcentrator = SpanConcentrator> { /* private fields */ }Expand description
An exporter that concentrates and sends stats to the agent.
Cap is the capabilities bundle (HTTP + sleep). Leaf crates pin it to a
concrete type (NativeCapabilities or WasmCapabilities).
Implementations§
Source§impl<Cap: HttpClientCapability + SleepCapability + MaybeSend + Sync + 'static, Con: FlushableConcentrator> StatsExporter<Cap, Con>
impl<Cap: HttpClientCapability + SleepCapability + MaybeSend + Sync + 'static, Con: FlushableConcentrator> StatsExporter<Cap, Con>
Sourcepub fn new(
flush_interval: Duration,
concentrator: Arc<Mutex<Con>>,
meta: StatsMetadata,
endpoint: Endpoint,
capabilities: Cap,
) -> Self
pub fn new( flush_interval: Duration, concentrator: Arc<Mutex<Con>>, meta: StatsMetadata, endpoint: Endpoint, capabilities: Cap, ) -> Self
Return a new StatsExporter
flush_intervalthe interval on which the concentrator is flushedconcentratoran impl ofFlushableConcentratorstoring the stats to be sent to the agentmetametadata used in ClientStatsPayload and as headers to send stats to the agentendpointthe Endpoint used to send stats to the agent
Sourcepub async fn send(&self, force_flush: bool) -> Result<bool>
pub async fn send(&self, force_flush: bool) -> Result<bool>
Flush the stats stored in the concentrator and send them
If the stats flushed from the concentrator contain at least one time bucket the stats are
sent to self.endpoint. The stats are serialized as msgpack.
§Errors
The function will return an error in the following case:
- The endpoint failed to build
- The stats payload cannot be serialized as a valid http body
- The http client failed while sending the request
- The http status of the response is not 2xx
§Panic
Will panic if another thread panicked while holding the concentrator lock in which
case stats cannot be flushed since the concentrator might be corrupted.
Returns Ok(true) if stats were sent, Ok(false) if the concentrator had nothing to send.
Trait Implementations§
Source§impl<Cap: Debug + HttpClientCapability + SleepCapability + MaybeSend + Sync + 'static, Con: Debug + FlushableConcentrator> Debug for StatsExporter<Cap, Con>
impl<Cap: Debug + HttpClientCapability + SleepCapability + MaybeSend + Sync + 'static, Con: Debug + FlushableConcentrator> Debug for StatsExporter<Cap, Con>
Source§impl<Cap: HttpClientCapability + SleepCapability + MaybeSend + Sync + 'static, Con: FlushableConcentrator + Send + Debug> Worker for StatsExporter<Cap, Con>
impl<Cap: HttpClientCapability + SleepCapability + MaybeSend + Sync + 'static, Con: FlushableConcentrator + Send + Debug> Worker for StatsExporter<Cap, Con>
Source§fn run<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn run<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Flush and send stats on every trigger.
Source§fn trigger<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn trigger<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
run to wait for the next run.
This function should be cancellation safe as it can be cancelled at any yield point.