feat: app-usage Prometheus metrics + Grafana dashboard + Helm scrape#22
Merged
Conversation
Node-environment test files (server-side metrics) share the global afterEach teardown but lack jsdom's localStorage. Guard the clear() centrally instead of shimming per-file. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Increment demo_views_total after resolving the demo, so bogus /demo/*/* paths (SvelteKit runs page + layout load concurrently, so the layout 404 does not stop the page load) can't create unbounded label series, and failed S3 fetches no longer count as views. Add a test pinning the two grafana dashboard copies in sync.
Contributor
Author
OCP smoke test (infra-dev) — scrape confirmed ✅Built this branch (
Side finding: this branch also fixes the current dev CrashLoopBackOffThe running |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds application-usage metrics to the SvelteKit (adapter-node) server, exposes them for Prometheus, and ships a Grafana dashboard.
src/lib/server/metrics.ts):prom-clientwith default process/nodejs metrics plus three custom metrics —http_requests_total,http_request_duration_seconds(labelsmethod/route/status_code) anddemo_views_total(labelsclient/name). HMR double-registration guard.handlehook (src/hooks.server.ts): servesGET /metrics(excluded from its own counter) and times/counts every other request, labeled by the templatedroute.id(bounded cardinality — never the raw URL).demo_views_totalincremented in the demo route load, after the demo is validated, so bogus/demo/*/*paths can't create unbounded label series and failed S3 fetches don't count as views.mclabelsdependency subchart → rendersprometheus.io/scrape|port|pathannotations (port 8080,/metrics) andmapcolonies.io/*labels, gated onmclabels.prometheus.enabled.grafana/maps-playground-dashboard.jsonshipped as a sidecar-provisioned ConfigMap (gated onmetrics.grafanaDashboard.enabled, configurable discovery label). Panels: request rate by route, p50/p95 latency, error ratio, top demos, process mem/cpu.vitest-setup.tsguard so node-env test files share the global teardown, plus a test pinning the two dashboard JSON copies in sync.Test Plan
npm test— 35 passing (8 files), incl. metrics registry, handle hook, demo-view counter, dashboard-sync.npm run check— 0 errors.helm lint helmclean;helm template helmrenders scrape annotations when enabled, none when disabled; Grafana ConfigMap gated correctly./metricsand the dashboard auto-loads via the Grafana sidecar.🤖 Generated with Claude Code