package opentelemetry
Install
Dune Dependency
Authors
Maintainers
Sources
sha256=7c674ecf1851d23cc520dad81ac1135ad4ac2460e54985dfe655fcfda265a713
sha512=34f585d9961d0c9ad908f479b3cf93cadc9602ffc39ec37396c8613cc76ae3e2fbaf5446a51c4820cc02b16e01d6df74cb607e3fa1b291d1847f2d76b31f5f0e
doc/opentelemetry.ambient-context/Opentelemetry_ambient_context/index.html
Module Opentelemetry_ambient_context
Source
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.t
created inside thewith_binding k v (fun _ -> …)
will inherit thek := v
assignment.
- for Eio, fibers created inside
with_binding k v (fun () -> …)
will inherit thek := v
assignment. 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_types
module type STORAGE = Types.STORAGE
type 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()
.