Skip to content

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

feat: add Go server heap to monitoring chart

Boschdf4857e4b159
diff --git a/dashboard/src/components/molecules/TabsChart.tsx b/dashboard/src/components/molecules/TabsChart.tsx
index 240168df..c648a21c 100644
--- a/dashboard/src/components/molecules/TabsChart.tsx
+++ b/dashboard/src/components/molecules/TabsChart.tsx
@@ -7,11 +7,16 @@ import {
Tooltip,
ResponsiveContainer,
} from "recharts";
-import type { TabDataPoint, MemoryDataPoint } from "../../stores/useAppStore";
+import type {
+ TabDataPoint,
+ MemoryDataPoint,
+ ServerDataPoint,
+} from "../../stores/useAppStore";
interface Props {
data: TabDataPoint[];
memoryData?: MemoryDataPoint[];
+ serverData?: ServerDataPoint[];
instances: { id: string; profileName: string }[];
selectedInstanceId: string | null;
onSelectInstance: (id: string) => void;
@@ -39,6 +44,7 @@ function formatTime(timestamp: number): string {
export default function TabsChart({
data,
memoryData,
+ serverData,
instances,
selectedInstanceId,
onSelectInstance,
@@ -51,24 +57,35 @@ export default function TabsChart({
return colors;
}, [instances]);
- // Merge tab and memory data by timestamp
+ // Merge tab, memory, and server data by timestamp
const mergedData = useMemo(() => {
- if (!memoryData || memoryData.length === 0) return data;
+ const memByTime = new Map((memoryData || []).map((m) => [m.timestamp, m]));
+ const serverByTime = new Map(
+ (serverData || []).map((s) => [s.timestamp, s]),
+ );
- const memByTime = new Map(memoryData.map((m) => [m.timestamp, m]));
return data.map((d) => {
- const mem = memByTime.get(d.timestamp);
- if (!mem) return d;
- // Add memory keys with _mem suffix
const merged: Record<string, number> = { ...d };
- for (const [key, val] of Object.entries(mem)) {
- if (key !== "timestamp") {
- merged[`${key}_mem`] = val;
+
+ // Add memory keys with _mem suffix
+ const mem = memByTime.get(d.timestamp);
+ if (mem) {
+ for (const [key, val] of Object.entries(mem)) {
+ if (key !== "timestamp") {
+ merged[`${key}_mem`] = val;
+ }
}
}
+
+ // Add server metrics
+ const srv = serverByTime.get(d.timestamp);
+ if (srv) {
+ merged.goHeapMB = srv.goHeapMB;
+ }
+
return merged;
});
- }, [data, memoryData]);
+ }, [data, memoryData, serverData]);
if (data.length === 0 || instances.length === 0) {
return (
@@ -79,13 +96,19 @@ export default function TabsChart({
}
const hasMemory = memoryData && memoryData.length > 0;
+ const hasServer = serverData && serverData.length > 0;
return (
<div className="rounded-lg border border-border-subtle bg-bg-surface">
<ResponsiveContainer width="100%" height={200}>
<LineChart
data={mergedData}
- margin={{ top: 16, right: hasMemory ? 50 : 16, bottom: 8, left: 8 }}
+ margin={{
+ top: 16,
+ right: hasMemory || hasServer ? 50 : 16,
+ bottom: 8,
+ left: 8,
+ }}
>
<XAxis
dataKey="timestamp"
@@ -105,7 +128,7 @@ export default function TabsChart({
axisLine={false}
width={30}
/>
- {hasMemory && (
+ {(hasMemory || hasServer) && (
<YAxis
yAxisId="memory"
orientation="right"
@@ -128,10 +151,12 @@ export default function TabsChart({
}}
labelFormatter={(label) => formatTime(label as number)}
formatter={(value, name) => {
- const isMemory = String(name).endsWith("_mem");
- const instId = isMemory
- ? String(name).replace("_mem", "")
- : String(name);
+ const nameStr = String(name);
+ if (nameStr === "goHeapMB") {
+ return [`${value}MB`, "Server Heap"];
+ }
+ const isMemory = nameStr.endsWith("_mem");
+ const instId = isMemory ? nameStr.replace("_mem", "") : nameStr;
const inst = instances.find((i) => i.id === instId);
const label = inst?.profileName || instId;
return [
@@ -181,6 +206,19 @@ export default function TabsChart({
dot={false}
/>
))}
+ {/* Server heap line (dotted, gray) */}
+ {hasServer && (
+ <Line
+ yAxisId="memory"
+ type="monotone"
+ dataKey="goHeapMB"
+ name="goHeapMB"
+ stroke="#888"
+ strokeWidth={1.5}
+ strokeDasharray="2 2"
+ dot={false}
+ />
+ )}
</LineChart>
</ResponsiveContainer>
</div>
diff --git a/dashboard/src/pages/MonitoringPage.tsx b/dashboard/src/pages/MonitoringPage.tsx
index eeb90bc6..eb0d8077 100644
--- a/dashboard/src/pages/MonitoringPage.tsx
+++ b/dashboard/src/pages/MonitoringPage.tsx
@@ -14,10 +14,12 @@ export default function MonitoringPage() {
setInstancesLoading,
tabsChartData,
memoryChartData,
+ serverChartData,
currentTabs,
currentMemory,
addChartDataPoint,
addMemoryDataPoint,
+ addServerDataPoint,
setCurrentTabs,
setCurrentMemory,
settings,
@@ -48,9 +50,10 @@ export default function MonitoringPage() {
try {
// Fetch tabs always, metrics only if enabled
- const [allTabs, allMetrics] = await Promise.all([
+ const [allTabs, allMetrics, serverMetrics] = await Promise.all([
api.fetchAllTabs().catch(() => []),
memoryEnabled ? api.fetchAllMetrics().catch(() => []) : [],
+ api.fetchServerMetrics().catch(() => null),
]);
const tabsArray = Array.isArray(allTabs) ? allTabs : [];
@@ -86,6 +89,14 @@ export default function MonitoringPage() {
memDataPoint as Parameters<typeof addMemoryDataPoint>[0],
);
}
+ if (serverMetrics) {
+ addServerDataPoint({
+ timestamp,
+ goHeapMB: serverMetrics.goHeapAllocMB,
+ goroutines: serverMetrics.goNumGoroutine,
+ rateBucketHosts: serverMetrics.rateBucketHosts,
+ });
+ }
setCurrentTabs(tabsByInstance);
setCurrentMemory(memoryByInstance);
} catch (e) {
@@ -96,6 +107,7 @@ export default function MonitoringPage() {
memoryEnabled,
addChartDataPoint,
addMemoryDataPoint,
+ addServerDataPoint,
setCurrentTabs,
setCurrentMemory,
]);
@@ -151,6 +163,7 @@ export default function MonitoringPage() {
<TabsChart
data={tabsChartData}
memoryData={memoryEnabled ? memoryChartData : undefined}
+ serverData={serverChartData}
instances={runningInstances.map((i) => ({
id: i.id,
profileName: i.profileName,
diff --git a/dashboard/src/services/api.ts b/dashboard/src/services/api.ts
index c8ef1533..2aec5b1c 100644
--- a/dashboard/src/services/api.ts
+++ b/dashboard/src/services/api.ts
@@ -75,6 +75,17 @@ export async function fetchAllMetrics(): Promise<InstanceMetrics[]> {
return request<InstanceMetrics[]>("/instances/metrics");
}
+export interface ServerMetrics {
+ goHeapAllocMB: number;
+ goNumGoroutine: number;
+ rateBucketHosts: number;
+}
+
+export async function fetchServerMetrics(): Promise<ServerMetrics> {
+ const res = await request<{ metrics: ServerMetrics }>("/metrics");
+ return res.metrics;
+}
+
// Agents — endpoint is /api/agents (dashboard API)
export async function fetchAgents(): Promise<Agent[]> {
return request<Agent[]>("/api/agents");
diff --git a/dashboard/src/stores/useAppStore.ts b/dashboard/src/stores/useAppStore.ts
index d82020c5..04b7d1e3 100644
--- a/dashboard/src/stores/useAppStore.ts
+++ b/dashboard/src/stores/useAppStore.ts
@@ -19,6 +19,13 @@ export interface MemoryDataPoint {
[instanceId: string]: number; // jsHeapUsedMB
}
+export interface ServerDataPoint {
+ timestamp: number;
+ goHeapMB: number;
+ goroutines: number;
+ rateBucketHosts: number;
+}
+
interface AppState {
// Profiles
profiles: Profile[];
@@ -35,10 +42,12 @@ interface AppState {
// Chart data (persists across navigation)
tabsChartData: TabDataPoint[];
memoryChartData: MemoryDataPoint[];
+ serverChartData: ServerDataPoint[];
currentTabs: Record<string, InstanceTab[]>;
currentMemory: Record<string, number>; // instanceId -> jsHeapUsedMB
addChartDataPoint: (point: TabDataPoint) => void;
addMemoryDataPoint: (point: MemoryDataPoint) => void;
+ addServerDataPoint: (point: ServerDataPoint) => void;
setCurrentTabs: (tabs: Record<string, InstanceTab[]>) => void;
setCurrentMemory: (memory: Record<string, number>) => void;
@@ -109,6 +118,7 @@ export const useAppStore = create<AppState>((set) => ({
// Chart data
tabsChartData: [],
memoryChartData: [],
+ serverChartData: [],
currentTabs: {},
currentMemory: {},
addChartDataPoint: (point) =>
@@ -119,6 +129,10 @@ export const useAppStore = create<AppState>((set) => ({
set((state) => ({
memoryChartData: [...state.memoryChartData.slice(-59), point], // Keep last 60 points
})),
+ addServerDataPoint: (point) =>
+ set((state) => ({
+ serverChartData: [...state.serverChartData.slice(-59), point], // Keep last 60 points
+ })),
setCurrentTabs: (currentTabs) => set({ currentTabs }),
setCurrentMemory: (currentMemory) => set({ currentMemory }),