pub struct TelemetryOutageQueue<T> { /* private fields */ }Expand description
A count-and-byte bounded queue for exporter adapters.
This type does not create a task or thread. The exporter remains owned by the service’s
existing lifecycle and calls Self::drain_batch from that owned worker.
Implementations§
Source§impl<T> TelemetryOutageQueue<T>
impl<T> TelemetryOutageQueue<T>
Sourcepub fn new(limits: TelemetryQueueLimits) -> Self
pub fn new(limits: TelemetryQueueLimits) -> Self
Creates an empty queue with validated limits.
Sourcepub fn try_enqueue(
&self,
item: T,
estimated_bytes: usize,
) -> TelemetryEnqueueOutcome
pub fn try_enqueue( &self, item: T, estimated_bytes: usize, ) -> TelemetryEnqueueOutcome
Attempts to admit a telemetry record without waiting for an exporter lock.
estimated_bytes must include the envelope and attribute payload estimate used by the
owning exporter. A zero estimate is accounted as one byte so the byte budget always moves.
Sourcepub fn drain_batch(&self, max_items: usize, max_bytes: usize) -> Vec<T>
pub fn drain_batch(&self, max_items: usize, max_bytes: usize) -> Vec<T>
Removes a bounded FIFO batch for an exporter worker.
max_items and max_bytes are clamped to at least one. One admitted record may exceed
max_bytes; it is still returned alone so a worker can always make progress.
Sourcepub fn begin_shutdown(&self, deadline: Instant)
pub fn begin_shutdown(&self, deadline: Instant)
Stops new admission and binds shutdown to one absolute deadline.
Sourcepub fn poll_shutdown(
&self,
now: Instant,
) -> Option<TelemetryOutageShutdownReport>
pub fn poll_shutdown( &self, now: Instant, ) -> Option<TelemetryOutageShutdownReport>
Returns a final report once the queue drains or the absolute deadline expires.
Before the deadline, None means the exporter worker should continue draining. At the
deadline, all remaining records are dropped and included in the report.
Sourcepub fn snapshot(&self) -> TelemetryQueueSnapshot
pub fn snapshot(&self) -> TelemetryQueueSnapshot
Returns current queue occupancy and lifetime counters.