chronon::ObservableUnit
#include <ObservableUnit.hpp>
Public Functions
| Name | |
|---|---|
| virtual | ~ObservableUnit() =default |
| template <FixedString Fmt,typename... Args> void | warn(Args &&... args) |
| template <FixedString Track> void | spanEnd() |
| template <FixedString Track> void | spanEnd(uint16_t slot) |
| template <FixedString Track,typename Cat ,typename... Items> void | spanBegin(Cat category, EventNameRef name, Items &&... items) |
| template <FixedString Track,typename Cat ,typename... Items> void | spanBegin(uint16_t slot, Cat category, EventNameRef name, Items &&... items) |
| void | setObservationContext(ObservationContext * ctx) |
| void | registerTimelineTrack(TimelineTrackBase * track) |
| void | registerDerivedCounter(DerivedCounter * dc) |
| void | registerCounter(Counter * counter) |
| template <uint16_t Pipe,FixedString Stage,typename Cat ,typename... Items> void | pipeStageHex(Cat category, uint64_t id, Items &&... items) |
| template <FixedString Stage,typename Cat ,typename... Items> void | pipeStageHex(uint16_t pipe, Cat category, uint64_t id, Items &&... items) |
| template <uint16_t Pipe,FixedString Stage,typename Cat ,typename... Items> void | pipeStage(Cat category, uint64_t id, Items &&... items) |
| template <FixedString Stage,typename Cat ,typename... Items> void | pipeStage(uint16_t pipe, Cat category, uint64_t id, Items &&... items) |
| template <uint16_t Pipe,uint16_t Stage,typename Cat ,typename... Items> void | pipe(Cat category, uint64_t id, Items &&... items) |
| const ObservationStats & | observationStats() const |
| ObservationContext * | observationContext() |
| const ObservationContext * | observationContext() const |
| bool | observabilityEnabled() const |
| template <FixedString Track,typename Cat ,typename... Items> void | instant(Cat category, EventNameRef name, Items &&... items) |
| template <FixedString Fmt,typename... Args> void | info(Args &&... args) |
| virtual uint64_t | getObserveCycle() const |
| template <FixedString Name,typename Cat ,typename... Items> void | event(Cat category, Items &&... items) |
| template <FixedString Fmt,typename... Args> void | error(Args &&... args) |
| template <FixedString Fmt,typename... Args> void | debug(Args &&... args) |
| template <ObservationChannel Ch> const ObservationChannelStats & | channelStats() const |
Protected Attributes
| Name | |
|---|---|
| ObservationContext * | observe_ctx_ |
Friends
| Name | |
|---|---|
| class | chronon::sender::TickSimulation |
Detailed Description
class chronon::ObservableUnit;
ObservableUnit - Mixin providing observability to simulation units.
Inherit from this class (in addition to Unit) to add observation capabilities.
Usage:
inline const auto CACHE_HIT = Category<"cache_hit", "Cache hit">{};
class MyUnit : public TickableUnit, public ObservableUnit {
EventCounter ops_{this, "ops", "Operations executed"};
public:
void tick() override {
++ops_;
event<"cache_hit">(CACHE_HIT, arg<"addr">(addr));
debug<"Processing cycle {}">(cycle);
}
};
Public Functions Documentation
function ~ObservableUnit
virtual ~ObservableUnit() =default
function warn
template <FixedString Fmt,
typename... Args>
inline void warn(
Args &&... args
)
Emit a warning log message.
function spanEnd
template <FixedString Track>
inline void spanEnd()
function spanEnd
template <FixedString Track>
inline void spanEnd(
uint16_t slot
)
function spanBegin
template <FixedString Track,
typename Cat ,
typename... Items>
inline void spanBegin(
Cat category,
EventNameRef name,
Items &&... items
)
Open/close an occupancy span on a named track under this unit.
function spanBegin
template <FixedString Track,
typename Cat ,
typename... Items>
inline void spanBegin(
uint16_t slot,
Cat category,
EventNameRef name,
Items &&... items
)
function setObservationContext
inline void setObservationContext(
ObservationContext * ctx
)
Set the observation context.
Called by Simulation during unit initialization. Initializes all pending counters.
function registerTimelineTrack
inline void registerTimelineTrack(
TimelineTrackBase * track
)
Register a timeline lane/counter for initialization when context is attached.
Called by TimelineTrackBase constructor.
function registerDerivedCounter
inline void registerDerivedCounter(
DerivedCounter * dc
)
Register a derived counter for initialization when context is attached.
Called by DerivedCounter constructor.
function registerCounter
inline void registerCounter(
Counter * counter
)
Register a counter for initialization when context is attached.
Called by Counter constructor.
function pipeStageHex
template <uint16_t Pipe,
FixedString Stage,
typename Cat ,
typename... Items>
inline void pipeStageHex(
Cat category,
uint64_t id,
Items &&... items
)
function pipeStageHex
template <FixedString Stage,
typename Cat ,
typename... Items>
inline void pipeStageHex(
uint16_t pipe,
Cat category,
uint64_t id,
Items &&... items
)
function pipeStage
template <uint16_t Pipe,
FixedString Stage,
typename Cat ,
typename... Items>
inline void pipeStage(
Cat category,
uint64_t id,
Items &&... items
)
function pipeStage
template <FixedString Stage,
typename Cat ,
typename... Items>
inline void pipeStage(
uint16_t pipe,
Cat category,
uint64_t id,
Items &&... items
)
function pipe
template <uint16_t Pipe,
uint16_t Stage,
typename Cat ,
typename... Items>
inline void pipe(
Cat category,
uint64_t id,
Items &&... items
)
Emit a first-class pipeline slice whose pipe/stage are compile-time constants. The item id is both the visible Perfetto slice name and the flow id.
function observationStats
inline const ObservationStats & observationStats() const
Get per-unit observation stats (emitted/dropped per channel).
function observationContext
inline ObservationContext * observationContext()
Get the observation context.
Returns nullptr if not set (observability disabled).
function observationContext
inline const ObservationContext * observationContext() const
function observabilityEnabled
inline bool observabilityEnabled() const
Check if observability is enabled.
function instant
template <FixedString Track,
typename Cat ,
typename... Items>
inline void instant(
Cat category,
EventNameRef name,
Items &&... items
)
Emit an instant event on a named track under this unit.
function info
template <FixedString Fmt,
typename... Args>
inline void info(
Args &&... args
)
Emit an info log message.
function getObserveCycle
inline virtual uint64_t getObserveCycle() const
Get the current cycle for observation timestamps.
TickSimulation binds the owning unit's local cycle automatically when creating the unit. Standalone observers may override this method.
function event
template <FixedString Name,
typename Cat ,
typename... Items>
inline void event(
Cat category,
Items &&... items
)
Emit a low-cardinality instant event on this unit's shared "events" track.
function error
template <FixedString Fmt,
typename... Args>
inline void error(
Args &&... args
)
Emit an error log message.
function debug
template <FixedString Fmt,
typename... Args>
inline void debug(
Args &&... args
)
Emit a debug log message.
Usage: debug<"Processing request id={}">(request_id);
function channelStats
template <ObservationChannel Ch>
inline const ObservationChannelStats & channelStats() const
Get stats for a specific observation channel.
Protected Attributes Documentation
variable observe_ctx_
ObservationContext * observe_ctx_ = nullptr;
Friends
friend chronon::sender::TickSimulation
friend class chronon::sender::TickSimulation(
chronon::sender::TickSimulation
);
Updated on 2026-09-20 at 14:23:39 +0000