Documentation
¶
Overview ¶
Example: observability
Demonstrates drel's production observability surface — all opt-in via Options passed to Open, plus the OnQuery hook:
- WithLogger + WithQueryLog: structured slog line for every query.
- WithSlowQueryThreshold: queries slower than the threshold are flagged.
- WithTracer: one span per executed query (OpenTelemetry-style). This example plugs in a tiny in-memory tracer that counts spans.
- WithDevMode: development-time diagnostics — here it warns about an unbounded SELECT (no LIMIT).
- OnQuery: a raw hook receiving SQL, args, duration, and error for custom metrics/audit.
Runs against in-memory SQLite (pure-Go modernc.org/sqlite, no CGO).
Usage:
cd examples/observability go run ../../cmd/drel generate # generates catalog/product_drel.go + db/drel_gen.go go run .
Click to show internal directories.
Click to hide internal directories.