p2.7: prometheus /metrics

Default GET /metrics is Prometheus text; JSON stays at /metrics.json
and ?format=json. :8443 needs the metrics caller bearer; loopback
stays open. Restricted callers have no per-caller series and no
tavily:restricted gauge.
This commit is contained in:
2026-09-23 21:49:38 -07:00
parent c19a58d1e3
commit 4372673184
339 changed files with 73851 additions and 145 deletions
+25
View File
@@ -154,6 +154,31 @@ func (g *Gate) Release() {
g.wakeLocked()
}
func (g *Gate) Snapshot() (inflight, waiters int) {
if g == nil {
return 0, 0
}
g.mu.Lock()
defer g.mu.Unlock()
return g.inflight, len(g.waiters)
}
func (e *Engine) Stats() (calls uint64, fallback map[string]uint64) {
if e == nil {
return 0, nil
}
e.mu.Lock()
defer e.mu.Unlock()
if e.Fallback == nil {
return e.Calls, map[string]uint64{}
}
out := make(map[string]uint64, len(e.Fallback))
for k, v := range e.Fallback {
out[k] = v
}
return e.Calls, out
}
type Engine struct {
ChatURL string
EmbedURL string