Did you know that EventStoreDB has a Visualize tab?

Lokhesh Ujhoodha  |  01 August 2023

The picture above shows the visualize tab in EventStoreDB, displaying the entire lifetime of an order being placed to the order being shipped.

This feature has been present in EventStoreDB for 4 years now. This is only available in Event Store Cloud or the Enterprise version.

How does the visualization work?

You might have heard about the ​$by_correlation_id projection. Once enabled, every event which has a correlation id (that you can configure) set in its metadata will be processed by the projection and grouped into $bc-correlation-id streams.

What was new with this feature was how you could combine a $causationId in the event’s metadata to define what caused this particular event to happen. This allows you to select and view the complete life cycle of an order, in this case, using its correlation id.

How do you specify a causation ID

Let’s take the above example. We have a correlation id: order-4822 to correlate all events with that order. We know that everything starts with an OrderPlaced event. So let’s assume that we have an OrderPlaced event as follows:

Data : { … } Metadata: { “$correlationId”: “order-4822”}

For the sake of simplicity, let’s say that the event ID of the OrderPlaced event is 1234.

We know that the next thing which happens is a payment. So let’s create a PaymentMade event which points to the OrderPlaced event with event ID 1234.

Data : { … } Metadata: { “$correlationId”: “order-4822”, “$causationId”: “1234”}

We have omitted the data here as it's not relevant to this explanation. The important part is the metadata. The $correlationId stays the same to let EventStoreDB know that we are making a payment for order-4822. The $causationId is set to the event ID of the previous OrderPlaced event to let EventStoreDB know that PaymentMade is related to that particular OrderPlaced event.

That is all you need to do. The UI automatically refreshes and should display the branch immediately after PaymentMade is written. When you create two or more events that have the same $causationId you will see the graph branch into two or more.

If you're interested in this feature, get in touch to learn more about Event Store Cloud and the Enterprise version of EventStoreDB.