This commit is contained in:
2026-09-03 08:47:57 +02:00
parent 70ceb3cf81
commit 3d07a478c3
41 changed files with 1643 additions and 130 deletions
+42 -1
View File
@@ -549,7 +549,48 @@ def init_db():
["owner_kind", "owner_id", "scope", "lang"],
)
gateway_usage_ledger = get_table("gateway_usage_ledger")
for column, example in (("ttft_ms", 0.0), ("inter_token_ms", 0.0)):
for column, example in (
("created_at", ""),
("owner_kind", ""),
("owner_id", ""),
("backend", ""),
("endpoint", ""),
("requested_model", ""),
("model", ""),
("status_code", 0),
("success", 0),
("error_category", ""),
("upstream_latency_ms", 0.0),
("gateway_overhead_ms", 0.0),
("queue_wait_ms", 0.0),
("connect_ms", 0.0),
("total_latency_ms", 0.0),
("prompt_tokens", 0),
("completion_tokens", 0),
("cache_hit_tokens", 0),
("cache_miss_tokens", 0),
("reasoning_tokens", 0),
("total_tokens", 0),
("tokens_per_second", 0.0),
("context_window", 0),
("context_utilization", 0.0),
("cost_usd", 0.0),
("input_cost_usd", 0.0),
("output_cost_usd", 0.0),
("native_cost", 0),
("stream_requested", 0),
("temperature", 0.0),
("top_p", 0.0),
("max_tokens", 0),
("has_tools", 0),
("retries_attempted", 0),
("retry_succeeded", 0),
("circuit_open", 0),
("user_agent", ""),
("app_reference", ""),
("ttft_ms", 0.0),
("inter_token_ms", 0.0),
):
if not gateway_usage_ledger.has_column(column):
gateway_usage_ledger.create_column_by_example(column, example)
_index(db, "gateway_usage_ledger", "idx_gw_usage_time", ["created_at"])