feat: expose v02 webui performance metrics

This commit is contained in:
Codex Agent
2026-06-05 11:13:45 +08:00
parent 48e3d24ad6
commit ab7d79c69a
15 changed files with 901 additions and 28 deletions
+8 -1
View File
@@ -805,6 +805,12 @@ function v02MetricsSidecarAnnotations(metricsSidecarSha256) {
function v02MetricsSidecarContainer({ serviceId, namespace, gitopsTarget }) {
const service = v02ObservableService(serviceId);
assert.ok(service, `unknown v0.2 observable service ${serviceId}`);
const extraMetricsEnv = serviceId === "hwlab-cloud-api"
? [
{ name: "HWLAB_METRICS_EXTRA_URL", value: `http://127.0.0.1:${service.port}/v1/web-performance/metrics` },
{ name: "HWLAB_METRICS_EXTRA_TIMEOUT_MS", value: "2000" }
]
: [];
return {
name: "hwlab-metrics",
image: ciToolsRunnerImage,
@@ -816,7 +822,8 @@ function v02MetricsSidecarContainer({ serviceId, namespace, gitopsTarget }) {
{ name: "HWLAB_METRICS_GITOPS_TARGET", value: gitopsTarget },
{ name: "HWLAB_METRICS_PORT", value: "9100" },
{ name: "HWLAB_METRICS_TARGET_URL", value: `http://127.0.0.1:${service.port}${service.healthPath}` },
{ name: "HWLAB_METRICS_TARGET_TIMEOUT_MS", value: "2000" }
{ name: "HWLAB_METRICS_TARGET_TIMEOUT_MS", value: "2000" },
...extraMetricsEnv
],
ports: [{ name: "metrics", containerPort: 9100 }],
readinessProbe: { httpGet: { path: "/health/live", port: "metrics" }, initialDelaySeconds: 3, periodSeconds: 10 },
+5
View File
@@ -242,6 +242,11 @@ test("v02 render follows TypeScript runtime checks and does not self-patch boots
assert.match(workload.spec.template.metadata.annotations["hwlab.pikastech.local/metrics-sidecar-sha256"], /^[a-f0-9]{64}$/u);
assert.ok(sidecar.env.some((entry) => entry.name === "HWLAB_METRICS_SERVICE_ID" && entry.value === serviceId));
assert.ok(sidecar.ports.some((port) => port.name === "metrics" && port.containerPort === 9100));
if (serviceId === "hwlab-cloud-api") {
assert.ok(sidecar.env.some((entry) => entry.name === "HWLAB_METRICS_EXTRA_URL" && /\/v1\/web-performance\/metrics$/u.test(entry.value)), "cloud-api sidecar should scrape WebUI performance metrics from loopback");
} else {
assert.equal(sidecar.env.some((entry) => entry.name === "HWLAB_METRICS_EXTRA_URL"), false, `unexpected extra metrics target for ${serviceId}`);
}
}
const deepseekService = deepseekProxy.items.find((item) => item.kind === "Service" && item.metadata?.name === "hwlab-deepseek-proxy");
assert.equal(deepseekService.metadata.labels["hwlab.pikastech.local/monitoring"], "enabled");
+1 -1
View File
@@ -151,7 +151,7 @@ export const checkProfiles = Object.freeze({
{ id: "check-143-cloud-api-run-bun", group: "cloud-api", command: ["node","scripts/run-bun.mjs","scripts/code-agent-chat-smoke.mjs"] },
{ id: "check-144-cloud-api-run-bun", group: "cloud-api", command: ["node","scripts/run-bun.mjs","scripts/cloud-api-runtime-smoke.mjs"] },
{ id: "check-145-repo-bootstrap-skills-sh", group: "repo", command: ["sh","-n","scripts/bootstrap-skills.sh","scripts/worker-entrypoint.sh"] },
{ id: "check-146-cloud-api-run-bun", group: "cloud-api", command: ["node","scripts/run-bun.mjs","test","cmd/hwlab-cloud-api/runtime-options.test.ts","internal/cloud/access-control.test.ts","internal/cloud/code-agent-session-registry.test.ts","internal/cloud/json-rpc.test.ts","internal/cloud/m3-io-control.test.ts","internal/cloud/code-agent-trace-store.test.ts","internal/cloud/server-live-builds.test.ts","internal/cloud/server-health.test.ts","internal/cloud/server-agent-chat.test.ts","internal/cloud/server-m3-http.test.ts","internal/db/runtime-store.test.ts","internal/db/schema.test.ts"] }
{ id: "check-146-cloud-api-run-bun", group: "cloud-api", command: ["node","scripts/run-bun.mjs","test","cmd/hwlab-cloud-api/runtime-options.test.ts","internal/cloud/access-control.test.ts","internal/cloud/code-agent-session-registry.test.ts","internal/cloud/json-rpc.test.ts","internal/cloud/m3-io-control.test.ts","internal/cloud/code-agent-trace-store.test.ts","internal/cloud/server-live-builds.test.ts","internal/cloud/server-health.test.ts","internal/cloud/server-agent-chat.test.ts","internal/cloud/server-m3-http.test.ts","internal/cloud/web-performance.test.ts","internal/db/runtime-store.test.ts","internal/db/schema.test.ts"] }
])
});