# `ActorSimulation.Observer`
[🔗](https://github.com/d-led/gen_server_virtual_time/blob/v1.1.1/packages/actor_simulation/lib/actor_simulation/observer.ex#L1)

Collects message statistics for actors that are real servers rather than
simulated ones.

A simulated actor counts its own messages in its state. A real server in the
loop (see `ActorSimulation.add_process/3`) has no such state to extend, so
`ActorSimulation` instruments it with this observer and reads the counters back
with `VirtualTimeGenServer.snapshot/1`.

Counters live in the observed process, which is where the messages happen:
`on_receive/2` runs in the server, `on_send/2` in the process that sends.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
