Home / Companies / Pydantic / Blog / Post Details
Content Deep Dive

Why we ditched database triggers for audit logs

Blog post from Pydantic

Post Details
Company
Date Published
Author
-
Word Count
1,590
Company Posts That Month
13
Language
English
Hacker News Points
-
Post removed?
No
Summary

Audit logging, initially implemented using PostgreSQL triggers in Logfire's observability platform, faced challenges such as performance issues during data migrations, limited context, and difficulties in testing and debugging. The original system relied on database triggers to ensure automatic logging of every SQL operation, providing consistency by recording actions within the same transaction. However, this method required disabling triggers during bulk operations, leading to complications and "audit log spam." To address these issues, Logfire transitioned to application-level audit logging with Redis, adopting an asynchronous producer-consumer pattern. This new approach improved context handling, expanded audit coverage to non-database events, and eliminated the need for complex migration handling, though it introduced trade-offs like eventual consistency and dependency on Redis. The transition was executed incrementally, reinforcing the importance of adaptable and testable audit logging as business logic within the application.

Trends Found in this Post
Trend Post Mentions Total Month Mentions Posts Companies MoM
Observability 1 3,421 707 180 -24%
Real-time 1 5,735 1,391 247 -9%
Secrets Management 1 2,152 360 101 +18%
Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.