vtcode_commons/telemetry.rs
1use anyhow::Result;
2
3/// A lightweight sink used to record telemetry events emitted by extracted
4/// components. The `Event` type is intentionally generic so downstream
5/// consumers can supply their own event schema without depending on
6/// `vtcode-core` internals.
7pub trait TelemetrySink<Event>: Send + Sync {
8 /// Record an event produced by the component.
9 fn record(&self, event: &Event) -> Result<()>;
10
11 /// Flush any buffered telemetry data to its destination.
12 fn flush(&self) -> Result<()> {
13 Ok(())
14 }
15}
16
17/// A telemetry sink that ignores all events. Useful for tests or for consumers
18/// who do not need telemetry integration yet.
19#[derive(Debug, Default, Clone, Copy)]
20pub struct NoopTelemetry;
21
22impl<Event> TelemetrySink<Event> for NoopTelemetry {
23 fn record(&self, _event: &Event) -> Result<()> {
24 Ok(())
25 }
26}