use serde::{Deserialize, Serialize};
use std::collections::HashMap;
use crate::event::types::SeqNo;
use crate::web::HttpMethod;
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HttpPullTelemetry {
pub state: HttpPullState,
pub wait_reason: Option<WaitReason>,
pub next_wake_unix_secs: Option<u64>,
pub last_success_unix_secs: Option<u64>,
pub requests_total: u64,
pub responses_2xx: u64,
pub responses_4xx: u64,
pub responses_5xx: u64,
pub rate_limited_total: u64,
pub retries_total: u64,
pub events_decoded_total: u64,
pub wait_seconds_rate_limit: f64,
pub wait_seconds_poll_interval: f64,
pub wait_seconds_backoff: f64,
}
impl Default for HttpPullTelemetry {
fn default() -> Self {
Self {
state: HttpPullState::Fetching,
wait_reason: None,
next_wake_unix_secs: None,
last_success_unix_secs: None,
requests_total: 0,
responses_2xx: 0,
responses_4xx: 0,
responses_5xx: 0,
rate_limited_total: 0,
retries_total: 0,
events_decoded_total: 0,
wait_seconds_rate_limit: 0.0,
wait_seconds_poll_interval: 0.0,
wait_seconds_backoff: 0.0,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum HttpPullState {
Fetching,
Waiting,
Terminal,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum WaitReason {
RateLimit,
PollInterval,
Backoff,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AiChunkingSnapshot {
pub input_items_total: usize,
pub planned_items_total: usize,
pub excluded_items_total: usize,
pub chunk_count: usize,
pub rerender_attempts_total: u64,
pub max_decomposition_depth_reached: u32,
pub budget_overhead_tokens: u64,
pub oversize_policy: String,
pub exclusions_by_reason: HashMap<String, u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub excluded_items: Option<Vec<usize>>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HttpSurfaceMetricsSnapshot {
pub seq: SeqNo,
pub routes: Vec<HttpSurfaceRouteMetricsSnapshot>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct HttpSurfaceRouteMetricsSnapshot {
pub surface_name: String,
pub method: HttpMethod,
pub path: String,
pub status_class: String,
pub requests_total: u64,
pub request_duration_ms_total: u64,
pub request_bytes_total: u64,
pub response_bytes_total: u64,
}