Runtime\_events.Callbacks(3) OCaml library Runtime\_events.Callbacks(3)

# [NAME](#NAME)

Runtime\_events.Callbacks - no description

# [Module](#Module)

Module Runtime\_events.Callbacks

# [Documentation](#Documentation)

Module **Callbacks**  
: **sig end**

*type t*

Type of callbacks.

*val create* : **?runtime\_begin:(int -&gt;** **Runtime\_events.Timestamp.t -&gt;** **Runtime\_events.runtime\_phase -&gt; unit) -&gt;** **?runtime\_end:(int -&gt;** **Runtime\_events.Timestamp.t -&gt;** **Runtime\_events.runtime\_phase -&gt; unit) -&gt;** **?runtime\_counter:(int -&gt;** **Runtime\_events.Timestamp.t -&gt;** **Runtime\_events.runtime\_counter -&gt; int -&gt; unit) -&gt;** **?alloc:(int -&gt; Runtime\_events.Timestamp.t -&gt; int array -&gt; unit) -&gt;** **?lifecycle:(int -&gt;** **Runtime\_events.Timestamp.t -&gt;** **Runtime\_events.lifecycle -&gt; int option -&gt; unit) -&gt;** **?lost\_events:(int -&gt; int -&gt; unit) -&gt; unit -&gt; t**

Create a **Callback** that optionally subscribes to one or more runtime events. The first int supplied to callbacks is the ring buffer index. Each domain owns a single ring buffer for the duration of the domain's existence. After a domain terminates, a newly spawned domain may take ownership of the ring buffer. A **runtime\_begin** callback is called when the runtime enters a new phase (e.g a runtime\_begin with EV\_MINOR is called at the start of a minor GC). A **runtime\_end** callback is called when the runtime leaves a certain phase. The **runtime\_counter** callback is called when a counter is emitted by the runtime. **lifecycle** callbacks are called when the ring undergoes a change in lifecycle and a consumer may need to respond. **alloc** callbacks are currently only called on the instrumented runtime. **lost\_events** callbacks are called if the consumer code detects some unconsumed events have been overwritten.

*val add\_user\_event* : **'a Runtime\_events.Type.t -&gt;** **(int -&gt; Runtime\_events.Timestamp.t -&gt; 'a Runtime\_events.User.t -&gt; 'a -&gt; unit) -&gt;** **t -&gt; t**

**add\_user\_event ty callback t** extends **t** to additionally subscribe to user events of type **ty** . When such an event happens, **callback** is called with the corresponding event and payload.

2026-09-04 OCamldoc

---

Document: Runtime_events.Callbacks(3o) from ocaml 5.5.1-r0 (Chainguard OS)
Source: https://github.com/ocaml/ocaml
