otel: wire /otel into the SPA (dual-mode SX + sx-trigger poll refresh)
This commit is contained in:
@@ -481,13 +481,13 @@
|
||||
(traces (otel/recent-traces)))
|
||||
(quasiquote
|
||||
(div :id "otel-dashboard"
|
||||
;; The host serves single-body responses (no server-push SSE), so the
|
||||
;; dashboard stays live by reloading itself — every 3s it re-renders the
|
||||
;; latest metrics + trace. /otel/stream remains a snapshot of the newest
|
||||
;; span for any client that wants to poll it.
|
||||
(meta :http-equiv "refresh" :content "3")
|
||||
;; SPA-native live refresh: the SX engine polls GET /otel every 3s and
|
||||
;; swaps this div in place (outerHTML). The poll is a boosted request, so
|
||||
;; the route returns the text/sx fragment — no full reload, stays in the
|
||||
;; SPA. (No <meta refresh>, which would blow away the SPA shell.)
|
||||
:sx-get "/otel" :sx-trigger "every 3s" :sx-target "#otel-dashboard" :sx-swap "outerHTML"
|
||||
(h1 "OpenTelemetry")
|
||||
(p :style "font-size:0.8em;opacity:0.7" "live · auto-refreshes every 3s")
|
||||
(p :style "font-size:0.8em;opacity:0.7" "live · refreshes every 3s in-app")
|
||||
(h2 "latency by route")
|
||||
(p :style "font-size:0.75em;opacity:0.7"
|
||||
(span :style "color:#4c9a8f" "▉ p50") " "
|
||||
@@ -505,9 +505,16 @@
|
||||
(unquote (otel/-traces-list traces)))))))
|
||||
|
||||
;; ── routes ────────────────────────────────────────────────────────────
|
||||
;; Dual-mode, wired into the SPA: a boosted (SX-Request) fetch — a link click OR
|
||||
;; the 3s poll — gets the dashboard as a text/sx fragment the WASM kernel renders
|
||||
;; into place; a direct/no-JS load gets the full SPA shell (host/blog--page) with
|
||||
;; the dashboard in #content, so it degrades to a plain server-rendered page.
|
||||
;; (Reuses the host SPA shell + content-type negotiation from lib/host/blog.sx.)
|
||||
(define otel/dashboard-route
|
||||
(dream-get "/otel"
|
||||
(fn (req) (dream-html (render-to-html (otel/dashboard) {})))))
|
||||
(fn (req)
|
||||
(host/blog--resp req 200
|
||||
(host/blog--page req "OpenTelemetry" (otel/dashboard))))))
|
||||
(define otel/stream-route
|
||||
(dream-get "/otel/stream"
|
||||
(fn (req)
|
||||
|
||||
Reference in New Issue
Block a user