Trace vs Log Per Event: A Decision Tree
Some events belong in logs; some in traces. The decision tree that picks the right place per event class.
Trace if
The trace-vs-log decision per event is the fine-grained question of which observability primitive to use for each piece of telemetry. Traces and logs serve different purposes; using the wrong one produces telemetry that does not match how it gets queried. The discipline is matching the primitive to the access pattern.
What favors traces:
- It is part of a request flow.: Operations that happen as part of a request are spans within the request's trace. Database queries, downstream service calls, expensive computations within a request all fit naturally as spans.
- Spans are units of work within a trace.: A trace is a tree of spans. Each span represents a unit of work. The structure captures the relationships; the visualization shows the tree.
- It needs context propagation.: Operations that need to know about each other within the request use trace context. The context flows automatically; the operations are linked without manual wiring.
- Traces carry context naturally.: The trace is the context container. Operations within the trace share the trace ID; investigators see them grouped; the relationships are explicit.
- Performance analysis benefits.: Traces show timing relationships. Which span took longest; which spans ran in parallel; where time was spent. The information is hard to extract from logs; traces present it directly.
Traces are for request-scoped operations. The structure matches the access pattern.
Log if
What favors logs is different. Logs work for events that do not fit into a request flow; they work for high-cardinality data that traces cannot accommodate.
- It is async or batch.: Operations that happen outside request context (cron jobs, background workers, batch processing) are logs. There is no request to attach to; the log is the appropriate primitive.
- Logs are independent of request context.: Each log entry stands alone. It does not need to be part of a tree; it is a standalone fact recorded with its context.
- It contains high-cardinality info.: Customer IDs, full request bodies, complex objects. The cardinality of these can exceed what traces accommodate; logs handle high cardinality natively.
- Traces have attribute budgets.: Trace attributes are typically limited (some platforms cap at 100 or fewer per span). High-cardinality data does not fit. Logs have no equivalent constraint.
- Searchability matters.: If the data needs to be searchable by content, logs are the right place. Traces are queryable but typically by structure, not by content. The use case determines the primitive.
Logs are for high-cardinality data and async events. The primitive matches the access pattern.
Both if
Some events warrant both. The trace captures the in-flow context; the log provides searchability. The redundancy is small cost for high value.
- High-stakes events deserve both.: Critical operations: payments, account changes, security-relevant actions. These deserve full observability; the small cost of duplication is worth the increased visibility.
- Trace for in-flow context.: The trace shows where the operation fits in the request flow. The context is preserved; investigation has the structural information.
- Log for searchability.: The log records the operation with full searchability. Investigation can find the event by any of its attributes; the search supports retrospective investigation.
- Cost of both is small for important events.: The events that warrant both are infrequent. The cost of duplicating their telemetry is bounded; the value of duplicated observability is significant.
- The redundancy is worth it.: Critical events should not be lost to the limitations of either primitive. The redundancy ensures the team can find and investigate them through either path.
Trace vs log decision per event is the discipline of producing telemetry that matches the access pattern. Nova AI Ops integrates with both primitives, supports the per-event decision, and produces the unified view that investigation actually uses.