package opentelemetry
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha256=ca92e7395495f73b46316607c514ce0dbe5fab129dddd9a17b353f835dcbf77d
sha512=ea2afd07c8db955364681f90388959db97d7b7f5b0836bc4045eca929968d6d77905e3aa66802226c0791c2552d0e281bdf2dbfe7ed90e9877ce3cedc343823f
doc/opentelemetry.ambient-context/Opentelemetry_ambient_context/index.html
Module Opentelemetry_ambient_contextSource
Ambient context.
The ambient context, like the Matrix, is everywhere around you.
It is responsible for keeping track of that context in a manner that's consistent with the program's choice of control flow paradigm:
- for synchronous/threaded/direct style code, TLS ("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.
- for Lwt, any
'a Lwt.tcreated inside thewith_binding k v (fun _ -> …)will inherit thek := vassignment.
- for Eio, fibers created inside
with_binding k v (fun () -> …)will inherit thek := vassignment. This is consistent with the structured concurrency approach of Eio.
The only data stored by this storage is a Hmap.t, ie a heterogeneous map. Various users (libraries, user code, etc.) can create their own key to store what they are interested in, without affecting other parts of the storage.
module Types := Opentelemetry_ambient_context_typesmodule type STORAGE = Types.STORAGEtype storage = (module STORAGE)A key that can be mapped to values of type 'a in the ambient context.
Total order on keys
Create a new fresh key, distinct from any previously created key.
Get the current value for a given key, or None if no value was associated with the key in the ambient context.
with_binding k v cb calls cb() in a context in which k is bound to v. This does not affect storage outside of cb().