otel: child spans in the blog render path (waterfall breakdown)

This commit is contained in:
2026-07-02 11:44:00 +00:00
parent ca80df9ade
commit 76941277fd

View File

@@ -2003,7 +2003,9 @@
(define host/blog-post (define host/blog-post
(fn (req) (fn (req)
(let ((slug (dream-param req "slug"))) (let ((slug (dream-param req "slug")))
(let ((r (host/blog-get slug))) ;; child spans nest under the request's root span (from otel/instrument-route),
;; so the waterfall breaks the render down: get → body-fold → relations → …
(let ((r (otel/with-span "blog.get" {} (fn () (host/blog-get slug)))))
(if r (if r
;; Compute everything that does durable reads — body, related block, AND ;; Compute everything that does durable reads — body, related block, AND
;; the auth footer (a durable session read now) — in let bindings BEFORE ;; the auth footer (a durable session read now) — in let bindings BEFORE
@@ -2014,21 +2016,24 @@
;; (default just :body) via the render-fold, in field order, against a ;; (default just :body) via the render-fold, in field order, against a
;; context (auth/device/locale + the container). Else the legacy sx_content. ;; context (auth/device/locale + the container). Else the legacy sx_content.
(body-html (body-html
(let ((ctx (host/blog--comp-ctx principal req slug))) (otel/with-span "blog.render-body" {}
(let ((rendered (reduce (fn (acc f) (str acc (host/comp-render (host/blog--comp-of slug f) ctx))) (fn ()
"" (host/blog--composition-fields slug)))) (let ((ctx (host/blog--comp-ctx principal req slug)))
(if (= rendered "") (host/blog-render r) rendered)))) (let ((rendered (reduce (fn (acc f) (str acc (host/comp-render (host/blog--comp-of slug f) ctx)))
"" (host/blog--composition-fields slug))))
(if (= rendered "") (host/blog-render r) rendered))))))
;; all relation blocks (Related, Tags, Types, Tagged-with-this …) ;; all relation blocks (Related, Tags, Types, Tagged-with-this …)
;; come from iterating the registry — one section, registry-driven. ;; come from iterating the registry — one section, registry-driven.
(relations (host/blog--relations-or-hint slug (not (nil? principal)))) (relations (otel/with-span "blog.relations" {}
(fn () (host/blog--relations-or-hint slug (not (nil? principal))))))
;; the typed render-template block (Slice 8c) — field values shown via ;; the typed render-template block (Slice 8c) — field values shown via
;; the post's types' templates. A durable read, so pre-fetch it here. ;; the post's types' templates. A durable read, so pre-fetch it here.
(typed-block (host/blog--typed-block slug)) (typed-block (otel/with-span "blog.typed-block" {} (fn () (host/blog--typed-block slug))))
;; a TYPE post shows its definition (fields + grammar + relations) publicly — ;; a TYPE post shows its definition (fields + grammar + relations) publicly —
;; read-only; the edit page has the writable form. ;; read-only; the edit page has the writable form.
(type-def-view (if (host/blog--is-type? slug) (host/blog--type-def-view slug) "")) (type-def-view (if (host/blog--is-type? slug) (host/blog--type-def-view slug) ""))
(type-population (if (host/blog--is-type? slug) (host/blog--type-population slug) "")) (type-population (if (host/blog--is-type? slug) (host/blog--type-population slug) ""))
(auth-foot (host/auth-footer req))) (auth-foot (otel/with-span "blog.auth-footer" {} (fn () (host/auth-footer req)))))
(host/blog--resp req 200 (host/blog--resp req 200
(host/blog--page req (get r :title) (host/blog--page req (get r :title)
(quasiquote (quasiquote