pub struct TelemetryEmitter { /* private fields */ }Expand description
Helper for emitting telemetry events from nodes.
Provides best-effort, non-blocking emission with automatic rate limiting
and drop accounting. Uses try_send() to never block audio processing.
§Drop Accounting
Dropped events are tracked and can be reported via health telemetry.
Call emit_health() periodically to report dropped event counts.
Implementations§
Source§impl TelemetryEmitter
impl TelemetryEmitter
Sourcepub fn new(
node_id: String,
session_id: Option<String>,
tx: Option<Sender<TelemetryEvent>>,
) -> Self
pub fn new( node_id: String, session_id: Option<String>, tx: Option<Sender<TelemetryEvent>>, ) -> Self
Create a new telemetry emitter for a node.
Sourcepub fn emit(&self, event_type: &str, data: JsonValue) -> bool
pub fn emit(&self, event_type: &str, data: JsonValue) -> bool
Best-effort emit a telemetry event. Never blocks.
Returns true if the event was sent (or queued), false if dropped.
Sourcepub fn emit_with_correlation(
&self,
event_type: &str,
correlation_id: &str,
data: JsonValue,
) -> bool
pub fn emit_with_correlation( &self, event_type: &str, correlation_id: &str, data: JsonValue, ) -> bool
Emit an event with a correlation ID for grouping related events.
Sourcepub fn emit_with_turn(
&self,
event_type: &str,
turn_id: &str,
data: JsonValue,
) -> bool
pub fn emit_with_turn( &self, event_type: &str, turn_id: &str, data: JsonValue, ) -> bool
Emit an event with a turn ID for voice agent conversation grouping.
Emit an event with both correlation and turn IDs.
Sourcepub fn dropped_counts(&self) -> (u64, u64)
pub fn dropped_counts(&self) -> (u64, u64)
Get the current dropped event counts.
Sourcepub fn maybe_emit_health(&mut self) -> bool
pub fn maybe_emit_health(&mut self) -> bool
Emit a health event if the interval has passed or if there are dropped events.
Returns true if a health event was emitted.
Sourcepub fn set_rate_limit(&self, max_per_second: u32)
pub fn set_rate_limit(&self, max_per_second: u32)
Configure rate limiting for this emitter.
§Panics
Panics if the internal rate limit mutex is poisoned (indicates a prior panic).