Skip to content
Hiep Lam
Go back

Part 6: Observability and the Recap - Correlation IDs, the Cheat Sheet, the Glossary

Edit page đŸ‡»đŸ‡ł Tiáșżng Việt

“Event-Driven Architecture: The Top 10 Classic Problems” - Part 6 of 7 (closing the series). Ms. TĂ­ calls support: “where’s my order?” In a monolith, TĂšo greps one log file, reads one stack trace, done. At MuaLáșč, order #4711 has passed through 5 services and 3 topics - each service with its own log, separated by the broker’s silences. “Where did this request die” turns into a cross-service investigation. This is the bonus problem that closes the series, alongside a lookup table and glossary covering everything from the previous six parts.


1. Observability - debugging without a call stack

What is it? In a synchronous system, a request is one chain of function calls - a single process’s stack trace and logs tell the whole story. In an event-driven system, one business transaction is many disconnected pieces of work, running in different processes, stitched together through a broker - there’s no call stack spanning the whole thing. When something breaks, the question isn’t “which line failed” but “which piece of the chain ran, which didn’t, and which ran wrong” - and by default, no tool can answer that unless you seed the clues yourself, ahead of time.

Why does it happen? Because context breaks every time a message crosses the broker: the thread processing on the consumer side has no relationship to the thread that published - different process, different moment, sometimes a different machine. Everything that automatically “follows the flow” in a synchronous system (thread-local context, a stack trace, the current transaction) falls away at that boundary. To reconnect the story, the clue has to travel inside the message itself.

How do you fix it? Seed a clue into every event.

flowchart LR
  T["Ms. Ti clicks Place order - generates correlationId corr-8f3a"] --> O["OrderService logs: corr-8f3a"]
  O -->|"event carries header correlationId: corr-8f3a"| B["Broker"]
  B --> P["PaymentService logs: corr-8f3a"]
  B --> I["InventoryService logs: corr-8f3a"]
  B --> N["NotificationService logs: corr-8f3a - SMTP error"]
  P -->|"the next event also carries corr-8f3a"| B

A correlation ID flows through the system like a tracer dye in a water main: search corr-8f3a in a centralized log system → immediately see which 4 pieces ran, which one failed, and when. The unbreakable rule: whenever a consumer publishes a follow-up event, it must copy the correlation ID from the event it’s processing - break one link, and the whole thread is gone.

2. Recap - the whole series in four sentences

(1) Choosing event-driven architecture means choosing to put a network and a middleman between every conversation - which means events can be lost, and the only defense against loss (acknowledge, then resend) creates duplicates. (2) Since duplication and reordering can’t be eliminated at the source, a durable system doesn’t chase perfect infrastructure - it designs the business logic to be immune: idempotency for duplicates, version numbers for reordering, compensating transactions for work left half-done. (3) Everything else is flow management (backoff, DLQs, backpressure, prioritization) and promise management (consistency levels, schema contracts). (4) And because it’s all distributed, seed observability into every message before you need it.

Cheat sheet: problem → property → pattern → cost

#ProblemCore propertySolving patternCost
1Lost eventsDelivery guarantee, durability, ackacks=all + replication; ack after processingSlower; creates duplicates (→2)
2Duplicate eventsIdempotency, dedupIdempotent consumer: key + processed_events table in one transactionOne more table + one more constraint on every consumer
3Dual-writeAtomicityTransactional outbox; CDC (Debezium)Added latency + a relay to operate; still at-least-once (→2)
4Getting retries rightBackoff, jitter, circuit breakerClassify errors; exponential backoff + jitter; retry topics; circuit breakerMore complexity; non-blocking retry breaks ordering (→6)
5Poison messagesDead-lettering, redriveMax attempts → DLQ + alert + a human ownerAn unattended DLQ is a new flavor of lost event
6Out-of-order eventsPer-key ordering, causality, commutativityPartition key on the aggregate; version numbers; commutative designGiving up global ordering; risk of hot partitions (→9)
7Eventual consistencyStaleness, read-your-own-writesPer-read-path consistency level; optimistic UI; version tokensUX and mental model must accept “still updating”
8Cross-service transactionsSaga, compensating transaction, semantic lockSaga (choreography / orchestration) + compensating logicMust write and test an undo path per step
9Lag & overloadBackpressure, failover, hot partitionsScale by partition count; pull/prefetch; priority topics; load sheddingPlan partitions early; rebalancing creates duplicates (→2)
10Schema evolutionContract, backward/forward compatibilityAdditive-only rule; expand-contract; schema registryBig changes take three deliberate phases
+Can’t debug itTraceability, correlationCorrelation ID; OpenTelemetry; the 4 metrics; event replayDiscipline of seeding context in EVERY service, no exceptions

Glossary - every property in one screen

3. Sources


← Previous: Part 5 - Backpressure & Schema Evolution · This closes the series.

The series - Event-Driven Architecture: The Top 10 Classic Problems: 0 · Foundations · 1 · Lost & Duplicate Events · 2 · Outbox & Retries · 3 · Poison Messages & Ordering · 4 · Consistency & Sagas · 5 · Backpressure & Schema Evolution · 6 · Observability & Recap (you are here)


Edit page
Share this post:

Previous Post
Part 5: Backpressure and Schema Evolution - Overload and the Data Contract
Next Post
Re-reading a Campaign Runner After Its Ports-and-Adapters Refactor - Entry Point, Run Flow, and How to Debug It

Keep reading

A few more pieces in the same vein.

Rather read on your own time? Subscribe via RSS