Module Opentelemetry_ambient_context

Just forward to the ambient-context library

include module type of struct include Ambient_context end
include module type of struct include Ambient_context_core end
module Context = Ambient_context.Context
module Storage = Ambient_context.Storage
val default_storage : Ambient_context_core.Storage.t
val get_current_storage : unit -> Storage.t
val set_current_storage : Storage.t -> unit

Functions operating with the current storage

val get_context : unit -> Ambient_context_core.Context.t

Get the context from the current storage, or Hmap.empty if there is no ambient context.

val with_context : Ambient_context_core.Context.t -> (unit -> 'a) -> 'a

with_context ctx f calls f() in an ambient context in which get_context() will return ctx. Once f() returns, the storage is reset to its previous value.

val get : 'a Context.key -> 'a option

Get the ambient context and then look up k in it

val new_key : unit -> 'a Context.key

Create a new key

val with_key_bound_to : 'a Hmap.key -> 'a -> (unit -> 'b) -> 'b

with_key_bound_to storage k v f calls f() in a context updated to have k map to v.

val with_key_unbound : 'a Hmap.key -> (unit -> 'b) -> 'b

with_key_unbound k f calls f() in a context updated to have k bound to no value.