mirror of
https://github.com/ocaml-tracing/ocaml-opentelemetry.git
synced 2026-03-09 04:17:56 -04:00
2 lines
6.9 KiB
HTML
2 lines
6.9 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><title>Opentelemetry_ambient_context (opentelemetry.Opentelemetry_ambient_context)</title><meta charset="utf-8"/><link rel="stylesheet" href="../../_odoc-theme/odoc.css"/><meta name="generator" content="odoc 2.4.4"/><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">opentelemetry</a> » Opentelemetry_ambient_context</nav><header class="odoc-preamble"><h1>Module <code><span>Opentelemetry_ambient_context</span></code></h1><p>Ambient context.</p><p>The ambient context, like the Matrix, is everywhere around you.</p><p>It is responsible for keeping track of that context in a manner that's consistent with the program's choice of control flow paradigm:</p><ul><li>for synchronous/threaded/direct style code, <b>TLS</b> ("thread local storage") keeps track of a global variable per thread. Each thread has its own copy of the variable and updates it independently of other threads.</li></ul><ul><li>for Lwt, any <code>'a Lwt.t</code> created inside the <code>with_binding k v (fun _ -> …)</code> will inherit the <code>k := v</code> assignment.</li></ul><ul><li>for Eio, fibers created inside <code>with_binding k v (fun () -> …)</code> will inherit the <code>k := v</code> assignment. This is consistent with the structured concurrency approach of Eio.</li></ul><p>The only data stored by this storage is a <a href="../../hmap/Hmap/index.html#type-t"><code>Hmap.t</code></a>, ie a heterogeneous map. Various users (libraries, user code, etc.) can create their own <a href="#type-key"><code>key</code></a> to store what they are interested in, without affecting other parts of the storage.</p></header><div class="odoc-content"><div class="odoc-spec"><div class="spec module-substitution anchored" id="module-Types"><a href="#module-Types" class="anchor"></a><code><span><span class="keyword">module</span> Types := <a href="../Opentelemetry_ambient_context_types/index.html">Opentelemetry_ambient_context_types</a></span></code></div></div><div class="odoc-spec"><div class="spec module-type anchored" id="module-type-STORAGE"><a href="#module-type-STORAGE" class="anchor"></a><code><span><span class="keyword">module</span> <span class="keyword">type</span> STORAGE</span><span> = <a href="../Opentelemetry_ambient_context_types/module-type-STORAGE/index.html">Types.STORAGE</a></span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-storage"><a href="#type-storage" class="anchor"></a><code><span><span class="keyword">type</span> storage</span><span> = <span>(<span class="keyword">module</span> <a href="../Opentelemetry_ambient_context_types/module-type-STORAGE/index.html">STORAGE</a>)</span></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-default_storage"><a href="#val-default_storage" class="anchor"></a><code><span><span class="keyword">val</span> default_storage : <a href="#type-storage">storage</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get_current_storage"><a href="#val-get_current_storage" class="anchor"></a><code><span><span class="keyword">val</span> get_current_storage : <span>unit <span class="arrow">-></span></span> <a href="#type-storage">storage</a></span></code></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-set_storage_provider"><a href="#val-set_storage_provider" class="anchor"></a><code><span><span class="keyword">val</span> set_storage_provider : <span><a href="#type-storage">storage</a> <span class="arrow">-></span></span> unit</span></code></div></div><div class="odoc-spec"><div class="spec type anchored" id="type-key"><a href="#type-key" class="anchor"></a><code><span><span class="keyword">type</span> <span>'a key</span></span></code></div><div class="spec-doc"><p>A key that can be mapped to values of type <code>'a</code> in the ambient context.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-compare_key"><a href="#val-compare_key" class="anchor"></a><code><span><span class="keyword">val</span> compare_key : <span>int <span class="arrow">-></span></span> <span>int <span class="arrow">-></span></span> int</span></code></div><div class="spec-doc"><p>Total order on keys</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-create_key"><a href="#val-create_key" class="anchor"></a><code><span><span class="keyword">val</span> create_key : <span>unit <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <a href="#type-key">key</a></span></span></code></div><div class="spec-doc"><p>Create a new fresh key, distinct from any previously created key.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-get"><a href="#val-get" class="anchor"></a><code><span><span class="keyword">val</span> get : <span><span><span class="type-var">'a</span> <a href="#type-key">key</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> option</span></span></code></div><div class="spec-doc"><p>Get the current value for a given key, or <code>None</code> if no value was associated with the key in the ambient context.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-with_binding"><a href="#val-with_binding" class="anchor"></a><code><span><span class="keyword">val</span> with_binding : <span><span><span class="type-var">'a</span> <a href="#type-key">key</a></span> <span class="arrow">-></span></span> <span><span class="type-var">'a</span> <span class="arrow">-></span></span> <span><span>(<span>unit <span class="arrow">-></span></span> <span class="type-var">'r</span>)</span> <span class="arrow">-></span></span> <span class="type-var">'r</span></span></code></div><div class="spec-doc"><p><code>with_binding k v cb</code> calls <code>cb()</code> in a context in which <code>k</code> is bound to <code>v</code>. This does not affect storage outside of <code>cb()</code>.</p></div></div><div class="odoc-spec"><div class="spec value anchored" id="val-without_binding"><a href="#val-without_binding" class="anchor"></a><code><span><span class="keyword">val</span> without_binding : <span><span><span class="type-var">'a</span> <a href="#type-key">key</a></span> <span class="arrow">-></span></span> <span><span>(<span>unit <span class="arrow">-></span></span> <span class="type-var">'b</span>)</span> <span class="arrow">-></span></span> <span class="type-var">'b</span></span></code></div><div class="spec-doc"><p><code>without_binding k cb</code> calls <code>cb()</code> in a context where <code>k</code> has no binding (possibly shadowing the current ambient binding of <code>k</code> if it exists).</p></div></div></div></body></html>
|