Opentelemetry.Scope
Scopes.
A scope is a trace ID and the span ID of the currently active span.
type t = {
trace_id : Trace_id.t;
span_id : Span_id.t;
mutable events : Event.t list;
mutable attrs : key_value list;
}
val to_span_ctx : t -> Span_ctx.t
Turn the scope into a span context
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.
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 ambient_scope_key : t Ambient_context.key
The opaque key necessary to access/set the ambient scope with Ambient_context
.
Obtain current scope from Ambient_context
, if available.
val with_ambient_scope : t -> (unit -> 'a) -> 'a0
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.