Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 6 additions & 18 deletions crates/tw-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -387,17 +387,6 @@ pub enum Event {
status: Option<u16>,
at_ms: u64,
},
/// 磁盘空间的档位变了,记录随之减少或停止。
///
/// **用户点开一个请求发现没有正文时,得知道那不是 bug。**
StorageChanged {
id: u64,
/// `ok` = 全记;`metadata_only` = 不再存正文;`stopped` = 连记录也停了
level: String,
/// 还剩多少可用空间
free_bytes: u64,
at_ms: u64,
},
/// 上游在响应头里报了订阅额度。
///
/// **零成本**:不发额外请求,顺着真实流量白捡。按量付费的账号没有
Expand Down Expand Up @@ -548,7 +537,6 @@ impl Event {
| Event::ModelsChanged { id, .. }
| Event::ProxyChanged { id, .. }
| Event::AuthChanged { id, .. }
| Event::StorageChanged { id, .. }
| Event::Redacted { id, .. }
| Event::ToolCallFlagged { id, .. }
| Event::ResponseInspected { id, .. }
Expand Down Expand Up @@ -2197,14 +2185,14 @@ pub struct LeakGroup {
pub masked: Vec<String>,
}

/// 观测这一层现在能不能写。
/// 观测这一层在不在记。
///
/// **不看磁盘还剩多少。**那是操作系统的事,网关管好自己占的那一份就够了
/// —— 正文按天数和总量回收(见 `tw_store::blobs`),摘要按天数回收。
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StorageStatus {
/// - `ok`:正常记录
/// - `metadata_only`:磁盘空间不足,只记请求摘要,不保存请求体和响应体
/// - `stopped`:磁盘空间严重不足,停止记录
/// - `unavailable`:请求记录没有启动(数据库打不开之类)
pub level: String,
/// 请求记录启动了没有。`false` = 数据库打不开之类,这段时间的请求都不会留下
pub recording: bool,
/// 记了多少条
pub rows: i64,
/// 请求体占了多少字节
Expand Down
1 change: 0 additions & 1 deletion crates/tw-control/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ pub async fn bundle(State(s): State<ControlState>) -> String {
Some(store) => {
let g = store.lock().await;
let _ = writeln!(out, "\n## Request recording\n\n| | |\n|---|---|");
line(&mut out, "Disk state", g.level().label());
line(&mut out, "Requests recorded", g.db().count().unwrap_or(0));
line(
&mut out,
Expand Down
4 changes: 2 additions & 2 deletions crates/tw-control/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -929,15 +929,15 @@ async fn latency_by_provider(
async fn storage(State(s): State<ControlState>) -> Json<tw_api::StorageStatus> {
let Some(store) = &s.store else {
return Json(tw_api::StorageStatus {
level: "unavailable".into(),
recording: false,
rows: 0,
blob_bytes: 0,
forwarding_affected: false,
});
};
let g = store.lock().await;
Json(tw_api::StorageStatus {
level: g.level().slug().to_string(),
recording: true,
rows: g.db().count().unwrap_or(0),
blob_bytes: g.blobs().total_bytes(),
// **永远是 false。**观测挂了,代理照跑。哪天有人想改成
Expand Down
1 change: 0 additions & 1 deletion crates/tw-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ tw-observe = { workspace = true }
tw-pricing = { workspace = true }
bytes = { workspace = true }
rusqlite = { workspace = true }
libc = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
thiserror = { workspace = true }
Expand Down
139 changes: 0 additions & 139 deletions crates/tw-store/src/disk.rs

This file was deleted.

2 changes: 0 additions & 2 deletions crates/tw-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@

pub mod blobs;
pub mod db;
pub mod disk;
pub mod drift;
pub mod recorder;
pub mod task;

pub use blobs::{Blobs, Which};
pub use db::{Db, DbError, Latency, RequestRow, Summary};
pub use disk::{DiskLevel, free_bytes, level_for};
pub use recorder::{Recorder, price_source};
pub use task::StoredBody;
Loading
Loading