Struct SessionTelemetry
pub struct SessionTelemetry { /* private fields */ }Expand description
Zero-overhead telemetry collector for speech-to-speech sessions.
Designed for the three-lane processor model:
- Fast lane (sync, <1ms): No telemetry calls — pure audio/text forwarding.
- Telemetry lane (async, debounced): Calls
record_*methods on every event. These use only atomic operations — no allocations, no locks, no syscalls. - Control lane (async): Calls
snapshot()at turn boundaries to get aggregated stats as a JSON value ready to send to the browser.
Implementations§
§impl SessionTelemetry
impl SessionTelemetry
pub fn new() -> SessionTelemetry
pub fn new() -> SessionTelemetry
Create a new telemetry tracker, starting the session clock.
pub fn record_audio_out(&self, byte_len: usize)
pub fn record_audio_out(&self, byte_len: usize)
Record an outgoing audio chunk. Called from the telemetry lane.
pub fn record_vad_end(&self)
pub fn record_vad_end(&self)
Record VAD end (user stopped speaking).
pub fn record_text_send(&self)
pub fn record_text_send(&self)
Record that user sent a text message (for text-input latency tracking).
pub fn record_text_out(&self)
pub fn record_text_out(&self)
Record first model text output (TextDelta). Tracks text-input latency.
pub fn record_interruption(&self)
pub fn record_interruption(&self)
Record an interruption (barge-in).
pub fn record_turn_complete(&self)
pub fn record_turn_complete(&self)
Record turn completion for duration tracking.
pub fn record_usage(
&self,
total: Option<u32>,
prompt: Option<u32>,
response: Option<u32>,
cached: Option<u32>,
thoughts: Option<u32>,
)
pub fn record_usage( &self, total: Option<u32>, prompt: Option<u32>, response: Option<u32>, cached: Option<u32>, thoughts: Option<u32>, )
Record token usage from a UsageMetadata event.
pub fn mark_turn_start(&self)
pub fn mark_turn_start(&self)
Mark the beginning of a new turn (e.g., when model starts responding).
Trait Implementations§
§impl Default for SessionTelemetry
impl Default for SessionTelemetry
§fn default() -> SessionTelemetry
fn default() -> SessionTelemetry
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for SessionTelemetry
impl RefUnwindSafe for SessionTelemetry
impl Send for SessionTelemetry
impl Sync for SessionTelemetry
impl Unpin for SessionTelemetry
impl UnwindSafe for SessionTelemetry
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
Mutably borrows from an owned value. Read more