Hasty Briefsbeta

Bilingual

Wide logging: Stripe's canonical log line pattern

5 hours ago
  • #observability
  • #logging
  • #best-practices
  • Stripe's canonical log line pattern emphasizes wide logging, where one structured record per unit of work includes all important fields.
  • Key fields in a canonical log line include route, method, status, duration, user/account ID, request/trace ID, build/deploy ID, feature flags, downstream timings, and error codes.
  • Stripe treats canonical log lines as critical infrastructure, ensuring they are emitted even during exceptions and used for long-term analysis.
  • High-value fields for diagnosis include route templates, identity info, release metadata, execution cost, decision inputs, and outcomes.
  • The real benefit of wide logging is correlation, allowing better questions about incidents, releases, and customer issues.
  • High-cardinality fields like user_id and request_id are acceptable in wide events if the system supports filtering and grouping.
  • Common mistakes include logging only happy paths, raw paths instead of templates, and letting schema drift.
  • Implementation typically involves middleware that collects request-scoped data and emits a structured log line at the end.