feat(us-025): model usage statistics with rolling RPM windows and SQLite persistence
Adds _RollingCounter and _StatsCollector to the tracker: three rolling windows (hour=60×1min, day=24×1hr, month=30×1day) track request RPMs per model. GET /v1/stats returns combined local + peer stats. POST /v1/stats/gossip lets trackers push their local slice for additive merge in hive mode. SQLite persistence via --stats-db flag; stats survive tracker restarts. Records a stat for each proxied /v1/chat/completions request. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,12 @@ def main() -> None:
|
||||
default=None,
|
||||
help="This tracker's own URL as seen by peers (auto-derived from --host/--port if omitted)",
|
||||
)
|
||||
start_cmd.add_argument(
|
||||
"--stats-db",
|
||||
default=None,
|
||||
metavar="PATH",
|
||||
help="SQLite database path for persistent model usage statistics",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
@@ -44,6 +50,7 @@ def main() -> None:
|
||||
heartbeat_timeout=args.heartbeat_timeout,
|
||||
cluster_peers=cluster_peers or None,
|
||||
cluster_self_url=args.self_url,
|
||||
stats_db=getattr(args, "stats_db", None),
|
||||
)
|
||||
port = server.start()
|
||||
print(f"meshnet-tracker listening on http://{args.host}:{port}", flush=True)
|
||||
|
||||
Reference in New Issue
Block a user