package opentelemetry

  1. Overview
  2. Docs
Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source

Module Opentelemetry.Trace_providerSource

Sourceval get : unit -> Tracer.t

Get current tracer.

Sourceval set : Tracer.t -> unit

Set current tracer

Sourceval clear : unit -> unit

Replace current tracer by the dummy one. All spans will be discarded from now on.

Sourceval get_tracer : ?name:??? -> ?version:??? -> ?attrs:??? -> ?__MODULE__:??? -> unit -> Tracer.t

Get a tracer pre-configured with a fixed set of attributes added to every span it emits, forwarding to the current global tracer. Intended to be called once at the top of a library module.

  • parameter name

    instrumentation scope name (recorded as otel.scope.name)

  • parameter version

    instrumentation scope version (recorded as otel.scope.version)

  • parameter __MODULE__

    the OCaml module name, typically the __MODULE__ literal (recorded as code.namespace)

  • parameter attrs

    additional fixed attributes

Sourceval default_tracer : Tracer.t

A Tracer.t that lazily reads the global at emit time

Emit a span directly via the current global tracer

Sourceval with_thunk_and_finally : Tracer.t -> ?force_new_trace_id:??? -> ?trace_state:??? -> ?attrs:??? -> ?kind:??? -> ?trace_id:??? -> ?parent:??? -> ?links:??? -> string -> (Opentelemetry_core.Span.t -> 'a) -> (unit -> 'a) * ((unit, exn * Printexc.raw_backtrace) result -> unit)

Helper to implement with_ and similar functions

Sourceval with_ : ?tracer:??? -> ?force_new_trace_id:??? -> ?trace_state:??? -> ?attrs:??? -> ?kind:??? -> ?trace_id:??? -> ?parent:??? -> ?links:??? -> string -> (Opentelemetry_core.Span.t -> 'a) -> 'a

Sync span guard.

Notably, this includes implicit scope-tracking: if called without a ~scope argument (or ~parent/~trace_id), it will check in the Ambient_context for a surrounding environment, and use that as the scope. Similarly, it uses Scope.with_ambient_scope to set a new scope in the ambient context, so that any logically-nested calls to with_ will use this span as their parent.

NOTE be careful not to call this inside a Gc alarm, as it can cause deadlocks.

  • parameter tracer

    the tracer to use (default default_tracer)

  • parameter force_new_trace_id

    if true (default false), the span will not use a ambient scope, the ~scope argument, nor ~trace_id, but will instead always create fresh identifiers for this span