Files
synapbus/schema/002_trace_logging.sql
T
Algis DumbrisandClaude Opus 4.6 be098081b4 feat: implement trace logging, REST API, and observability
Add comprehensive trace logging and observability features:

- Enhanced trace store with owner-scoped queries, filtering (agent, action,
  time range), pagination, streaming export, and retention cleanup
- REST API endpoints: GET /api/traces (list with filters), GET /api/traces/export
  (streaming JSON/CSV), GET /api/traces/stats (action counts)
- Owner isolation enforced at every layer (store, API, tests)
- Hand-rolled Prometheus metrics (pure Go, zero CGO): traces_total,
  traces_by_action, errors_total, active_agents at GET /metrics
- Configurable slog JSON handler with --log-level flag
- Request ID middleware for cross-referencing logs and traces
- Batch trace writing (64 entries or 100ms flush interval)
- Background retention cleanup via --trace-retention flag
- SQL migration 002 adds owner_id column and composite indexes

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-13 11:57:05 +02:00

10 lines
490 B
SQL

-- Add owner_id to traces table for owner-scoped queries
ALTER TABLE traces ADD COLUMN owner_id TEXT NOT NULL DEFAULT '';
-- Composite indexes for efficient owner-scoped trace queries
CREATE INDEX idx_traces_owner_timestamp ON traces(owner_id, created_at);
CREATE INDEX idx_traces_owner_agent_timestamp ON traces(owner_id, agent_name, created_at);
CREATE INDEX idx_traces_owner_action_timestamp ON traces(owner_id, action, created_at);
INSERT INTO schema_migrations (version) VALUES (2);