Opentelemetry_traceopentelemetry.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.
Ambient_context is used to propagate the current span to child spans.
Trace_core.extension_event is used to expose OTEL-specific features on top of the common tracing interface, e.g. to set the span kind:
let@ span = Trace_core.with_span ~__FILE__ ~__LINE__ "my-span" in
Opentelemetry_trace.set_span_kind span Span_kind_client
(* ... *)module OTEL := Opentelemetry_coremodule Otrace := Trace_coremodule Extensions : sig ... endThe extension events for Trace_core.
Install the OTEL backend as a Trace collector. The trace collector will use Trace_provider.get, Log_provider.get, and Meter_provider.get to get the current tracer, logger, meter and use that to emit signals.
This will not do much until a proper OTEL.Exporter.t is installed via OTEL.Sdk.set.
val setup_with_otel_exporter : OTEL.Exporter.t -> unitSame as setup, but also calls OTEL.Sdk.set otel_exporter
val setup_with_otel_backend : OTEL.Exporter.t -> unitval collector : Trace_core.collectorMake a Trace collector that uses the main OTEL providers to emit traces, metrics, and logs
val ambient_span_provider : Trace_core.Ambient_span_provider.tUses Ambient_context to provide contextual spans in Trace_core. It is automatically installed by the collector.
val link_spans : Otrace.span -> Otrace.span -> unitlink_spans sp1 sp2 modifies sp1 by adding a span link to sp2.
val link_span_to_otel_ctx : Otrace.span -> OTEL.Span_ctx.t -> unitlink_spans sp1 sp_ctx2 modifies sp1 by adding a span link to sp_ctx2. It must be the case that sp1 is a currently active span.
val set_span_kind : Otrace.span -> OTEL.Span.kind -> unitset_span_kind sp k sets the span's kind.
val set_span_status : Otrace.span -> OTEL.Span_status.t -> unitval record_exception :
Otrace.span ->
exn ->
Stdlib.Printexc.raw_backtrace ->
unitRecord exception in the current span.
val with_ambient_span : Otrace.span -> (unit -> 'a) -> 'awith_ambient_span sp f calls f() in an ambient context where sp is the current span.
val with_ambient_span_ctx : OTEL.Span_ctx.t -> (unit -> 'a) -> 'awith_ambient_span_ctx spc f calls f() in a scope where spc is the ambient span-context
module Well_known : sig ... end