package opentelemetry

  1. Overview
  2. Docs

Module Opentelemetry.ScopeSource

Scopes.

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

Sourcetype item_list
Sourcetype t = {
  1. trace_id : Trace_id.t;
  2. span_id : Span_id.t;
  3. mutable items : item_list;
}
Sourceval attrs : t -> key_value list
Sourceval events : t -> Event.t list
Sourceval status : t -> Span_status.t option
Sourceval kind : t -> Span_kind.t option
Sourceval make : trace_id:Trace_id.t -> span_id:Span_id.t -> ?events:Event.t list -> ?attrs:key_value list -> ?links:Span_link.t list -> ?status:Span_status.t -> unit -> t

Turn the scope into a span link

Sourceval to_span_ctx : t -> Span_ctx.t

Turn the scope into a span context

Sourceval 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.

Sourceval record_exception : t -> exn -> Printexc.raw_backtrace -> unit
Sourceval add_attrs : t -> (unit -> key_value list) -> unit

Add attributes 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.

Add links to the scope. It will be aggregated into the span.

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

Sourceval set_status : t -> Span_status.t -> unit

set the span status.

Note that this function will be called only if there is an instrumentation backend.

Sourceval set_kind : t -> Span_kind.t -> unit

Set the span's kind.

  • since NEXT_RELEASE
Sourceval ambient_scope_key : t Ambient_context.key

The opaque key necessary to access/set the ambient scope with Ambient_context.

Sourceval get_ambient_scope : ?scope:t -> unit -> t option

Obtain current scope from Ambient_context, if available.

Sourceval with_ambient_scope : t -> (unit -> 'a) -> 'a

with_ambient_scope sc thunk calls thunk() in a context where sc is the (thread|continuation)-local scope, then reverts to the previous local scope, if any.

OCaml

Innovation. Community. Security.