Performance observability — dazzle perf¶
Local, on-demand OpenTelemetry tracing for any Dazzle project. Captures
a single trace run to .dazzle/perf/<run-id>.db and emits agent-friendly
findings on slow endpoints, slow queries, suspected N+1 patterns, slow
framework phases, and exceptions.
Install¶
Adds the OTel SDK + the three auto-instrumentations (fastapi,
psycopg, asyncio). No collector required — the bundled SQLite
exporter writes a self-contained trace file per run.
Workflow¶
- Capture a run while hitting one or more URLs:
Boots the app under tracing, hits the URLs, then keeps the server
alive for
--durationseconds so any background traffic (HTMX prefetch, websocket pings) also lands.
Authenticated traces¶
Most Dazzle apps gate the interesting paths behind login. To unlock those during a trace, pass credentials:
The runner POSTs to /auth/login/password (Dazzle's standard form-mode
endpoint), captures the dazzle_session cookie, and threads it through
every subsequent --url hit.
For OAuth/SSO flows where --login can't model the auth dance, pass
the session cookie directly:
--cookie is repeatable and works alongside (or instead of) --login.
When both are supplied, --login wins; the explicit cookie is ignored.
-
Read findings:
-
Dig deeper:
What gets instrumented¶
Automatically: - FastAPI requests - psycopg SQL queries - asyncio task spans
Manually (Dazzle's hot paths):
- dsl.parse — top-level parse
- predicate.compile — scope-rule SQL compile
- aggregate.expression.compile — L3 inner SQL compile
- aggregate.build_sql — GROUP BY composer
- repo.aggregate — outer Repository.aggregate call
- region.render — per-region render
- fragment.emit — fragment emission
Agent ergonomics¶
The Markdown report is the source of truth for agents — designed to
paste into a Claude conversation. Section structure is stable; an
agent can rely on ## Slow endpoints, ## Suspected N+1 patterns,
etc., as recognisable hooks.
For programmatic use, see docs/reference/perf-findings-schema.md.
MCP¶
The perf MCP tool exposes read-only operations: list, report,
show. The trace subcommand stays CLI-only because it spawns a
subprocess (ADR-0002).