Module Opentelemetry_trace

module Otel := Opentelemetry
module Otrace := Trace_core

opentelemetry.trace implements a Trace_core.Collector for ocaml-trace.

After installing this collector with setup, you can consume libraries that use ocaml-trace, and they will automatically emit OpenTelemetry spans and logs.

Both explicit scope (in the _manual functions such as enter_manual_span) and implicit scope (in Internal.M.with_span, via Ambient_context) are supported; see the detailed notes on Internal.M.enter_manual_span.

Well-known identifiers

Because ocaml-trace's API is a subset of OpenTelemetry functionality, this interface allows for a few 'well-known' identifiers to be used in Trace-instrumented libraries that wish to further support OpenTelemetry usage.

(These strings will not change in subsequent versions of this library, so you do not need to depend on opentelemetry.trace to use them.)

ocaml
let describe () = [ Opentelemetry_trace.(spankind_key, client) ] in
Trace_core.with_span ~__FILE__ ~__LINE__ ~data:describe "my-span"
@@ fun _ ->
  (* ... *)
val on_internal_error : (string -> unit) ref

Callback to print errors in the library itself (ie bugs)

val setup : unit -> unit

Install the OTEL backend as a Trace collector

val setup_with_otel_backend : Opentelemetry.Collector.backend -> unit

Same as setup, but also install the given backend as OTEL backend

val collector : unit -> Trace_core.collector

Make a Trace collector that uses the OTEL backend to send spans and logs

module Well_known : sig ... end

Static references for well-known identifiers; see Well-known identifiers.