Skip to content

Commit 9a6779f

Browse files
committed
Add System Health Postgres metrics panel
1 parent 0c0f2eb commit 9a6779f

15 files changed

Lines changed: 360 additions & 47 deletions

admin/system-health.html

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ <h2>Admin</h2>
5151
<p>Notifications &amp; Alerts</p>
5252
<p>Local API Startup</p>
5353
<p>Database Health</p>
54+
<p>Postgres Metrics</p>
5455
<p>Storage Health</p>
5556
<p>Runtime Health</p>
5657
<p>Health Check History</p>
@@ -293,6 +294,21 @@ <h3>Manual Health Actions</h3>
293294
</tbody>
294295
</table>
295296
</div>
297+
<div class="table-wrapper">
298+
<table class="data-table" aria-label="Postgres metrics">
299+
<caption>Postgres Metrics</caption>
300+
<thead>
301+
<tr>
302+
<th scope="col">Metric</th>
303+
<th scope="col">Safe Value</th>
304+
<th scope="col">Status</th>
305+
</tr>
306+
</thead>
307+
<tbody data-admin-system-health-postgres-metric-rows>
308+
<tr><td>Postgres metrics</td><td>Unavailable until safe API status loads</td><td data-health-status="PENDING" title="Reason: Postgres metrics have not loaded yet." aria-label="PENDING: Postgres metrics have not loaded yet.">PENDING</td></tr>
309+
</tbody>
310+
</table>
311+
</div>
296312
<div class="table-wrapper">
297313
<table class="data-table" aria-label="Storage health">
298314
<caption>Storage Health - Cloudflare R2</caption>

assets/theme-v2/js/admin-system-health.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ class AdminSystemHealthController {
7474
this.notificationRows = root.querySelector("[data-admin-system-health-notification-rows]");
7575
this.serviceCards = root.querySelector("[data-admin-system-health-service-cards]");
7676
this.startupRows = root.querySelector("[data-admin-system-health-startup-rows]");
77+
this.postgresMetricRows = root.querySelector("[data-admin-system-health-postgres-metric-rows]");
7778
this.runtimeRows = root.querySelector("[data-admin-system-health-runtime-rows]");
7879
}
7980

@@ -145,6 +146,7 @@ class AdminSystemHealthController {
145146
this.setStatus(key, "PENDING", reason);
146147
});
147148
this.renderStartupPending(reason);
149+
this.renderPostgresMetricsPending(reason);
148150
this.renderStoragePending(reason);
149151
this.renderRuntimeHealthPending(reason);
150152
this.renderEnvironmentCapabilitiesPending(reason);
@@ -213,6 +215,46 @@ class AdminSystemHealthController {
213215
this.setStatus("version", databaseStatus.versionStatus, reason);
214216
this.setValue("lastChecked", databaseStatus.lastChecked, "not available");
215217
this.setStatus("lastChecked", databaseStatus.lastChecked ? "PASS" : "WARN", reason);
218+
this.renderPostgresMetrics(databaseStatus.postgresMetrics || {});
219+
}
220+
221+
renderPostgresMetricsPending(reason) {
222+
if (!this.postgresMetricRows) {
223+
return;
224+
}
225+
const row = document.createElement("tr");
226+
row.append(
227+
this.createCell("Postgres metrics"),
228+
this.createCell("Unavailable"),
229+
this.createStatusCell("PENDING", reason),
230+
);
231+
this.postgresMetricRows.replaceChildren(row);
232+
}
233+
234+
renderPostgresMetrics(postgresMetrics = {}) {
235+
if (!this.postgresMetricRows) {
236+
return;
237+
}
238+
if (postgresMetrics?.secretsExposed === true || postgresMetrics?.secretEditingAllowed === true) {
239+
this.renderPostgresMetricsPending("Safe Postgres metrics response was blocked because it exposed secret controls.");
240+
return;
241+
}
242+
const rows = Array.isArray(postgresMetrics.rows) ? postgresMetrics.rows : [];
243+
if (!rows.length) {
244+
this.renderPostgresMetricsPending("Safe Admin System Health API returned no Postgres metric rows.");
245+
return;
246+
}
247+
const fragment = document.createDocumentFragment();
248+
rows.forEach((metricRow) => {
249+
const row = document.createElement("tr");
250+
row.append(
251+
this.createCell(metricRow.metric),
252+
this.createCell(metricRow.value),
253+
this.createStatusCell(metricRow.status, postgresMetrics.message),
254+
);
255+
fragment.append(row);
256+
});
257+
this.postgresMetricRows.replaceChildren(fragment);
216258
}
217259

218260
renderStorageStatus(storageStatus = {}) {
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel
2+
3+
Team: Charlie
4+
Branch: pr/26177-CHARLIE-029-system-health-postgres-metrics-panel
5+
Base: main
6+
Lifecycle: Build / Validation
7+
8+
## Scope
9+
- Added a System Health Postgres Metrics panel backed by the server-owned Admin System Health API.
10+
- Added safe current-environment metrics for connection status, database name, current schema, migration status, last migration, table count, database size, and last checked.
11+
- Preserved current-environment-only behavior and did not add cross-environment database checks.
12+
13+
## Changed Files
14+
- admin/system-health.html
15+
- assets/theme-v2/js/admin-system-health.js
16+
- src/dev-runtime/server/local-api-router.mjs
17+
- tests/api/admin-system-health/contract.test.mjs
18+
- tests/dev-runtime/AdminHealthOperations.test.mjs
19+
- tests/playwright/tools/AdminHealthOperationsPage.spec.mjs
20+
- docs_build/dev/reports/coverage_changed_js_guardrail.txt
21+
- docs_build/dev/reports/playwright_v8_coverage_report.txt
22+
23+
## Validation
24+
- PASS: node --check src/dev-runtime/server/local-api-router.mjs
25+
- PASS: node --check assets/theme-v2/js/admin-system-health.js
26+
- PASS: node --test tests/api/admin-system-health/contract.test.mjs
27+
- PASS: node --test tests/dev-runtime/AdminHealthOperations.test.mjs
28+
- PASS: npx playwright test tests/playwright/tools/AdminHealthOperationsPage.spec.mjs --workers=1 --reporter=line
29+
- PASS: git diff --check
30+
31+
## ZIP
32+
- Pending until commit: C:\Users\DavidQ\Documents\GitHub\HTML-JavaScript-Gaming\tmp\PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_delta.zip
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Branch Validation
2+
3+
Branch: pr/26177-CHARLIE-029-system-health-postgres-metrics-panel
4+
Expected start branch: main, then PR branch for build
5+
Current status at validation:
6+
## pr/26177-CHARLIE-029-system-health-postgres-metrics-panel
7+
M admin/system-health.html
8+
M assets/theme-v2/js/admin-system-health.js
9+
M docs_build/dev/reports/coverage_changed_js_guardrail.txt
10+
M docs_build/dev/reports/playwright_v8_coverage_report.txt
11+
M src/dev-runtime/server/local-api-router.mjs
12+
M tests/api/admin-system-health/contract.test.mjs
13+
M tests/dev-runtime/AdminHealthOperations.test.mjs
14+
M tests/playwright/tools/AdminHealthOperationsPage.spec.mjs
15+
16+
Result: PASS
17+
18+
Checks:
19+
- PASS: Started from synchronized main.
20+
- PASS: Active branch matches PR identity.
21+
- PASS: Worktree contained only scoped PR changes and generated validation reports.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Manual Validation Notes
2+
3+
- Confirmed Postgres Metrics appears as a separate System Health table.
4+
- Confirmed metric values come from the server-owned Admin System Health API response.
5+
- Confirmed unavailable metrics render visibly as Unavailable/WARN rather than silently falling back.
6+
- Confirmed page retains external scripts/styles only; no inline style/script/handler additions.
7+
- Confirmed no secrets or database URLs are shown in the Database Health or Postgres Metrics tables.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Requirement Checklist
2+
3+
- PASS: Add/extend System Health Postgres metrics panel.
4+
- PASS: Include connection status.
5+
- PASS: Include database name.
6+
- PASS: Include current schema/migration status when available.
7+
- PASS: Include table count when available.
8+
- PASS: Include database size when available.
9+
- PASS: Do not add expensive queries.
10+
- PASS: Show explicit Unavailable status when a metric is unavailable.
11+
- PASS: Do not expose secrets.
12+
- PASS: Keep browser UI consuming API/service contract.
13+
- PASS: No cross-environment checks added.
14+
- PASS: No start_of_day files modified.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# PR_26177_CHARLIE_029-system-health-postgres-metrics-panel Validation Lane Report
2+
3+
Impacted lanes:
4+
- runtime: Local API Admin System Health status contract.
5+
- contract: Admin System Health API contract tests.
6+
- UI: Admin System Health Theme V2 page controller and markup.
7+
- Playwright: targeted Admin System Health page spec.
8+
9+
Commands:
10+
- node --check src/dev-runtime/server/local-api-router.mjs
11+
- node --check assets/theme-v2/js/admin-system-health.js
12+
- node --test tests/api/admin-system-health/contract.test.mjs
13+
- node --test tests/dev-runtime/AdminHealthOperations.test.mjs
14+
- npx playwright test tests/playwright/tools/AdminHealthOperationsPage.spec.mjs --workers=1 --reporter=line
15+
- git diff --check
16+
17+
Skipped lanes:
18+
- Full samples smoke skipped; not impacted by System Health API/UI panel change.
19+
- Full workspace suite skipped; targeted Project Workspace coverage was sufficient for this scoped Admin page.
20+
21+
Result: PASS
Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,32 @@
1-
assets/theme-v2/js/gamefoundry-partials.js
2-
assets/theme-v2/js/legal-document-page.js
3-
assets/theme-v2/partials/footer.html
4-
docs_build/dev/reports/PR_26175_OWNER_054-legal-corrected-package.md
5-
docs_build/dev/reports/codex_changed_files.txt
6-
docs_build/dev/reports/codex_review.diff
7-
docs_build/dev/reports/coverage_changed_js_guardrail.txt
8-
docs_build/dev/reports/playwright_v8_coverage_report.txt
9-
legal/community-guidelines.html
10-
legal/community-guidelines.md
11-
legal/cookie-policy.html
12-
legal/cookie-policy.md
13-
legal/cookies-policy.html
14-
legal/copyright-policy.html
15-
legal/copyright-policy.md
16-
legal/disclaimer.html
17-
legal/dmca-policy.html
18-
legal/dmca-policy.md
19-
legal/index.html
20-
legal/index.md
21-
legal/legal-nav.js
22-
legal/privacy-policy.html
23-
legal/privacy-policy.md
24-
legal/terms.html
25-
legal/terms-of-service.html
26-
legal/terms-of-service.md
27-
tests/playwright/tools/RemainingLegalPages.spec.mjs
1+
# git status --short
2+
M admin/system-health.html
3+
M assets/theme-v2/js/admin-system-health.js
4+
M docs_build/dev/reports/coverage_changed_js_guardrail.txt
5+
M docs_build/dev/reports/playwright_v8_coverage_report.txt
6+
M src/dev-runtime/server/local-api-router.mjs
7+
M tests/api/admin-system-health/contract.test.mjs
8+
M tests/dev-runtime/AdminHealthOperations.test.mjs
9+
M tests/playwright/tools/AdminHealthOperationsPage.spec.mjs
10+
?? docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel.md
11+
?? docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_branch-validation.md
12+
?? docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_manual-validation-notes.md
13+
?? docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_requirements-checklist.md
14+
?? docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_validation-lane.md
15+
16+
# git ls-files --others --exclude-standard
17+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel.md
18+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_branch-validation.md
19+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_manual-validation-notes.md
20+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_requirements-checklist.md
21+
docs_build/dev/reports/PR_26177_CHARLIE_029-system-health-postgres-metrics-panel_validation-lane.md
22+
23+
# git diff --stat
24+
admin/system-health.html | 16 +++
25+
assets/theme-v2/js/admin-system-health.js | 42 ++++++++
26+
.../dev/reports/coverage_changed_js_guardrail.txt | 5 +-
27+
.../dev/reports/playwright_v8_coverage_report.txt | 29 ++++--
28+
src/dev-runtime/server/local-api-router.mjs | 115 +++++++++++++++++++--
29+
tests/api/admin-system-health/contract.test.mjs | 15 +++
30+
tests/dev-runtime/AdminHealthOperations.test.mjs | 20 ++++
31+
.../tools/AdminHealthOperationsPage.spec.mjs | 11 ++
32+
8 files changed, 233 insertions(+), 20 deletions(-)
-178 KB
Binary file not shown.

docs_build/dev/reports/coverage_changed_js_guardrail.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ Missing changed runtime JS files are WARN, not FAIL.
66
Source: Playwright/Chromium built-in V8 coverage from the active Playwright run.
77

88
Changed runtime JS files considered:
9-
(63%) assets/theme-v2/js/gamefoundry-partials.js - executed lines 1046/1046; executed functions 62/98
9+
(0%) src/dev-runtime/server/local-api-router.mjs - WARNING: changed runtime JS file was not collected by Playwright V8 coverage; advisory only
10+
(81%) assets/theme-v2/js/admin-system-health.js - executed lines 848/848; executed functions 70/86
1011

1112
Guardrail warnings:
12-
(100%) none - no changed runtime JS coverage warnings
13+
(0%) src/dev-runtime/server/local-api-router.mjs - WARNING: changed runtime JS file missing from coverage; advisory only

0 commit comments

Comments
 (0)