wide-events-logging
Installation
SKILL.md
Wide Events Logging (Canonical Log Lines)
Logging should not be a "debugging diary" where you sprinkle console.log("doing X") across your codebase. This creates log chaos: thousands of fragmented strings that are impossible to correlate or query effectively during an incident.
Instead, when instrumenting applications, implement Wide Events (also known as Canonical Log Lines).
Core Philosophy
- One Request, One Log Line: Emit exactly one comprehensive structured event per request, per service.
- Accumulate Context: Initialize an event object at the start of a request (usually in middleware), pass it down (or attach to context), enrich it with business data as the request executes, and log it in a
finallyblock or at the network boundary. - High Cardinality: Strongly prefer adding attributes with millions of possible values (e.g.,
user_id,request_id,cart_id) because these are the most valuable fields for pinpointing specific failures. - High Dimensionality: Don't just log HTTP status and duration. Log feature flags, user subscription tiers, database query counts, attempt numbers, and precise decline codes.