From 76941277fdc0abde874fda17ab0e85bdbd2bb741 Mon Sep 17 00:00:00 2001 From: giles Date: Thu, 2 Jul 2026 11:44:00 +0000 Subject: [PATCH] otel: child spans in the blog render path (waterfall breakdown) --- lib/host/blog.sx | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/host/blog.sx b/lib/host/blog.sx index 52433dc1..adf28cd3 100644 --- a/lib/host/blog.sx +++ b/lib/host/blog.sx @@ -2003,7 +2003,9 @@ (define host/blog-post (fn (req) (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 ;; Compute everything that does durable reads — body, related block, AND ;; 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 ;; context (auth/device/locale + the container). Else the legacy sx_content. (body-html - (let ((ctx (host/blog--comp-ctx principal req slug))) - (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)))) + (otel/with-span "blog.render-body" {} + (fn () + (let ((ctx (host/blog--comp-ctx principal req slug))) + (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 …) ;; 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 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 — ;; 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-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--page req (get r :title) (quasiquote