package opentelemetry

  1. Overview
  2. Docs

Module Opentelemetry.Thread_localSource

Thread/Domain local storage

This allows the creation of global state that is per-domain or per-thread.

Sourcetype 'a t
Sourceval create : unit -> 'a t

Create new storage

Sourceval get : 'a t -> 'a option

Get current value

Sourceval get_exn : 'a t -> 'a

Like get but fails with an exception

Sourceval with_ : 'a t -> 'a -> ('a option -> 'b) -> 'b

with_ var x f sets var to x for this thread, calls f prev where prev is the value currently in var (if any), and then restores the old value of var for this thread.