pub struct CacheTelemetryEvent {
pub request_id: Uuid,
pub agent_identity: AgentIdentity,
pub cache_read_tokens: u64,
pub cache_creation_tokens: u64,
pub total_prompt_tokens: u64,
pub hit_rate: f64,
pub miss_reason: Option<CacheMissReason>,
pub miss_diagnosis: Option<CacheMissDiagnosis>,
pub provider: String,
pub timestamp: DateTime<Utc>,
}Expand description
Per-call cache telemetry event.
Captures provider-agnostic cache metrics for a single LLM request.
The agent_identity field cross-references the Phase 3
AgentIdentity type for per-agent grouping.
Fields§
§request_id: UuidRequest ID this telemetry pertains to.
agent_identity: AgentIdentityIdentity of the agent that issued the request.
cache_read_tokens: u64Number of tokens served from cache.
cache_creation_tokens: u64Number of tokens written to cache.
total_prompt_tokens: u64Total prompt tokens (for hit rate calculation).
hit_rate: f64Computed cache hit rate [0.0, 1.0].
miss_reason: Option<CacheMissReason>Reason for cache miss, if applicable.
miss_diagnosis: Option<CacheMissDiagnosis>Structured miss diagnosis, when the miss can be justified safely.
provider: StringProvider name (e.g., “anthropic”, “openai”).
timestamp: DateTime<Utc>When this telemetry was recorded.
Implementations§
Source§impl CacheTelemetryEvent
impl CacheTelemetryEvent
Sourcepub fn compute_hit_rate(cache_read_tokens: u64, total_prompt_tokens: u64) -> f64
pub fn compute_hit_rate(cache_read_tokens: u64, total_prompt_tokens: u64) -> f64
Computes hit rate from token counts. Returns 0.0 if
total_prompt_tokens is zero to avoid division by zero.
Sourcepub fn from_usage(
request_id: Uuid,
agent_identity: AgentIdentity,
provider: CacheTelemetryProvider,
usage: &Usage,
timestamp: DateTime<Utc>,
request_facts: Option<&CacheRequestFacts>,
) -> Option<Self>
pub fn from_usage( request_id: Uuid, agent_identity: AgentIdentity, provider: CacheTelemetryProvider, usage: &Usage, timestamp: DateTime<Utc>, request_facts: Option<&CacheRequestFacts>, ) -> Option<Self>
Builds a canonical cache telemetry event from normalized usage fields.
Returns None when the normalized usage payload does not contain
prompt_tokens, because Phase 10 does not invent missing totals.
Trait Implementations§
Source§impl Clone for CacheTelemetryEvent
impl Clone for CacheTelemetryEvent
Source§fn clone(&self) -> CacheTelemetryEvent
fn clone(&self) -> CacheTelemetryEvent
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CacheTelemetryEvent
impl Debug for CacheTelemetryEvent
Source§impl<'de> Deserialize<'de> for CacheTelemetryEvent
impl<'de> Deserialize<'de> for CacheTelemetryEvent
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for CacheTelemetryEvent
impl PartialEq for CacheTelemetryEvent
Source§fn eq(&self, other: &CacheTelemetryEvent) -> bool
fn eq(&self, other: &CacheTelemetryEvent) -> bool
self and other values to be equal, and is used by ==.