mirror of
https://github.com/openai/codex.git
synced 2026-10-23 18:08:45 +00:00
## Why SQLite log persistence needs visibility into batch size, write latency, failures, and entries dropped before they reach the writer. Exporter diagnostics must not feed back into the SQLite log sink and keep metric exports active indefinitely. ## What changed - Record write count, duration, batch bytes, entry count, largest-entry size, and queue drops with bounded outcome tags. - Add explicit byte histogram boundaries for log batch metrics. - Filter OTLP transport noise and the benign unsolicited HTTP/2 PING warning from SQLite log persistence to prevent export cycles while retaining other HTTP/2 warnings. ## Testing - Cover metric values, tags, queue-drop reasons, and histogram boundaries. - Verify successful and failed OTLP HTTP and gRPC exports become idle instead of generating recurring SQLite log-write metrics. GitOrigin-RevId: a63224ae15945fe84adc977a8b7d55bb47a4de53
58 lines
1.6 KiB
Rust
58 lines
1.6 KiB
Rust
use serde::Serialize;
|
|
use sqlx::FromRow;
|
|
|
|
#[derive(Clone, Debug, Serialize)]
|
|
pub struct LogEntry {
|
|
pub ts: i64,
|
|
pub ts_nanos: i64,
|
|
pub level: String,
|
|
pub target: String,
|
|
pub message: Option<String>,
|
|
pub feedback_log_body: Option<String>,
|
|
pub thread_id: Option<String>,
|
|
pub process_uuid: Option<String>,
|
|
pub module_path: Option<String>,
|
|
pub file: Option<String>,
|
|
pub line: Option<i64>,
|
|
}
|
|
|
|
impl LogEntry {
|
|
pub(crate) fn estimated_bytes(&self) -> i64 {
|
|
let feedback_log_body = self.feedback_log_body.as_ref().or(self.message.as_ref());
|
|
feedback_log_body.map_or(0, String::len) as i64
|
|
+ self.level.len() as i64
|
|
+ self.target.len() as i64
|
|
+ self.module_path.as_ref().map_or(0, String::len) as i64
|
|
+ self.file.as_ref().map_or(0, String::len) as i64
|
|
}
|
|
}
|
|
|
|
#[derive(Clone, Debug, FromRow)]
|
|
pub struct LogRow {
|
|
pub id: i64,
|
|
pub ts: i64,
|
|
pub ts_nanos: i64,
|
|
pub level: String,
|
|
pub target: String,
|
|
pub message: Option<String>,
|
|
pub thread_id: Option<String>,
|
|
pub process_uuid: Option<String>,
|
|
pub file: Option<String>,
|
|
pub line: Option<i64>,
|
|
}
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
pub struct LogQuery {
|
|
pub levels_upper: Vec<String>,
|
|
pub from_ts: Option<i64>,
|
|
pub to_ts: Option<i64>,
|
|
pub module_like: Vec<String>,
|
|
pub file_like: Vec<String>,
|
|
pub thread_ids: Vec<String>,
|
|
pub search: Option<String>,
|
|
pub include_threadless: bool,
|
|
pub after_id: Option<i64>,
|
|
pub limit: Option<usize>,
|
|
pub descending: bool,
|
|
}
|