package opentelemetry

  1. Overview
  2. Docs

Scopes.

A scope is a trace ID and the span ID of the currently active span.

type t = {
  1. trace_id : Trace_id.t;
  2. span_id : Span_id.t;
  3. mutable events : Event.t list;
  4. mutable attrs : key_value list;
}
val add_event : t -> (unit -> Event.t) -> unit

Add an event to the scope. It will be aggregated into the span.

Note that this takes a function that produces an event, and will only call it if there is an instrumentation backend.

val add_attrs : t -> (unit -> key_value list) -> unit

Add an attr to the scope. It will be aggregated into the span.

Note that this takes a function that produces attributes, and will only call it if there is an instrumentation backend.

val get_surrounding : ?scope:t -> unit -> t option

Obtain current scope from thread-local storage, if available

val with_scope : t -> (unit -> 'a) -> 'a

with_scope sc f calls f() in a context where sc is the (thread)-local scope, then reverts to the previous local scope, if any.

OCaml

Innovation. Community. Security.