Skip to content

High-performance browser automation bridge and multi-instance orchestrator with advanced stealth injection and real-time dashboard.

fix: add /metrics endpoint to dashboard mode

Bosch14147f6f7754
diff --git a/cmd/pinchtab/cmd_dashboard.go b/cmd/pinchtab/cmd_dashboard.go
index d7c7bdd2..c2a9eb74 100644
--- a/cmd/pinchtab/cmd_dashboard.go
+++ b/cmd/pinchtab/cmd_dashboard.go
@@ -63,6 +63,10 @@ func runDashboard(cfg *config.RuntimeConfig) {
web.JSON(w, 200, map[string]string{"status": "ok", "mode": "dashboard"})
})
+ mux.HandleFunc("GET /metrics", func(w http.ResponseWriter, r *http.Request) {
+ web.JSON(w, 200, map[string]any{"metrics": handlers.SnapshotMetrics()})
+ })
+
// Special handler for /tabs - return empty list if no instances
mux.HandleFunc("GET /tabs", func(w http.ResponseWriter, r *http.Request) {
target := orch.FirstRunningURL()
diff --git a/internal/handlers/health_tabs.go b/internal/handlers/health_tabs.go
index 15b5a029..e5eab288 100644
--- a/internal/handlers/health_tabs.go
+++ b/internal/handlers/health_tabs.go
@@ -39,7 +39,7 @@ func (h *Handlers) HandleEnsureChrome(w http.ResponseWriter, r *http.Request) {
}
func (h *Handlers) HandleMetrics(w http.ResponseWriter, r *http.Request) {
- result := map[string]any{"metrics": snapshotMetrics()}
+ result := map[string]any{"metrics": SnapshotMetrics()}
// Aggregate memory metrics across all tabs
if h.Bridge != nil {
diff --git a/internal/handlers/metrics.go b/internal/handlers/metrics.go
index 848d5202..2f99a728 100644
--- a/internal/handlers/metrics.go
+++ b/internal/handlers/metrics.go
@@ -16,7 +16,7 @@ func RateBucketHostCount() int {
return len(rateBuckets)
}
-func snapshotMetrics() map[string]any {
+func SnapshotMetrics() map[string]any {
total := atomic.LoadUint64(&metricRequestsTotal)
failed := atomic.LoadUint64(&metricRequestsFailed)
latencySum := atomic.LoadUint64(&metricRequestLatencyN)