Skip to main content

Module narrate

Module narrate 

Source
Expand description

Rendering a run to a tracing subscriber as it happens.

The trace is the record; this is a view of it. Both come from one producer in one order, so there is no second account of the run to disagree with the first — which is the whole reason narration goes into the trace rather than straight to a subscriber.

§Why the driver renders, and not the protocol

tracing’s dispatcher is thread-local. A protocol calling tracing::info! would be reaching for something ambient, which constraint 2 exists to forbid, and it would get both of the facts a reader needs first wrong: five simulated processes share one thread, so nothing would say which process spoke, and a subscriber timestamps with the wall clock, which measures how long the simulation took rather than anything about the run being reproduced.

So protocols call Cx::note, the simulator records it, and only the simulator — a driver, which is allowed to — touches a dispatcher.

§As it is recorded, not at the end

A run that fails to terminate is one of the things worth reading, and a renderer that walked a finished trace would have nothing to show for it.