mirror of
https://github.com/c-cube/nanoev.git
synced 2025-12-05 19:00:35 -05:00
10 lines
3.4 KiB
HTML
10 lines
3.4 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Callbacks (trace.Trace_subscriber.Callbacks)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 3.0.0"/><meta name="viewport" content="width=device-width,initial-scale=1.0"/><script src="../../../highlight.pack.js"></script><script>hljs.initHighlightingOnLoad();</script></head><body class="odoc"><nav class="odoc-nav"><a href="../index.html">Up</a> – <a href="../../../index.html">Index</a> » <a href="../../index.html">trace</a> » <a href="../index.html">Trace_subscriber</a> » Callbacks</nav><header class="odoc-preamble"><h1>Module <code><span>Trace_subscriber.Callbacks</span></code></h1><p>Callbacks used for subscribers.</p><p>Each subscriber defines a set of callbacks, for each possible tracing event. These callbacks take a custom state that is paired with the callbacks in <a href="../Subscriber/index.html#type-t"><code>Subscriber.t</code></a>.</p><p>To use a default implementation for some callbacks, use:</p><pre class="language-ocaml"><code> module My_callbacks = struct
|
||
type st = …
|
||
|
||
include Trace_subscriber.Callbacks.Dummy
|
||
|
||
let on_init (state:st) ~time_ns : unit = …
|
||
|
||
(* … other custom callbacks … *)
|
||
end</code></pre><p><b>NOTE</b>: the <code>trace_id</code> passed alongside manual spans is guaranteed to be at least 64 bits.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec module-type anchored" id="module-type-S"><a href="#module-type-S" class="anchor"></a><code><span><span class="keyword">module</span> <span class="keyword">type</span> <a href="module-type-S/index.html">S</a></span><span> = <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>First class module signature for callbacks</p></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-t"><a href="#type-t" class="anchor"></a><code><span><span class="keyword">type</span> <span>'st t</span></span><span> = <span>(<span class="keyword">module</span> <a href="module-type-S/index.html">S</a> <span class="keyword">with</span> <span class="keyword">type</span> <a href="module-type-S/index.html#type-st">st</a> = <span class="type-var">'st</span>)</span></span></code></div><div class="spec-doc"><p>Callbacks for a subscriber. There is one callback per event in <a href="../../Trace/index.html"><code>Trace</code></a>. The type <code>'st</code> is the state that is passed to every single callback.</p></div></div><div class="odoc-spec"><div class="spec module anchored" id="module-Dummy"><a href="#module-Dummy" class="anchor"></a><code><span><span class="keyword">module</span> <a href="Dummy/index.html">Dummy</a></span><span> : <span class="keyword">sig</span> ... <span class="keyword">end</span></span></code></div><div class="spec-doc"><p>Dummy callbacks. It can be useful to reuse some of these functions in a real subscriber that doesn't want to handle <b>all</b> events, but only some of them.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-dummy"><a href="#val-dummy" class="anchor"></a><code><span><span class="keyword">val</span> dummy : <span>unit <span class="arrow">-></span></span> <span><span class="type-var">'st</span> <a href="#type-t">t</a></span></span></code></div><div class="spec-doc"><p>Dummy callbacks, ignores all events.</p></div></div></div></body></html>
|