From 59e2e854e55fc724169a14a72bfbb3e165931a91 Mon Sep 17 00:00:00 2001 From: Simon Cruanes Date: Wed, 15 Apr 2026 10:19:11 -0400 Subject: [PATCH] docs --- src/trace/opentelemetry_trace.ml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/trace/opentelemetry_trace.ml b/src/trace/opentelemetry_trace.ml index c3ed6a02..c3195f9b 100644 --- a/src/trace/opentelemetry_trace.ml +++ b/src/trace/opentelemetry_trace.ml @@ -1,6 +1,9 @@ open Common_ module Extensions = struct + (* extend [Trace]'s types with OTEL specific variants, eg to have a + [Trace.span] be a wrapper around [OTEL.Span.t], or to declare custom actions + to link spans together, or to be able to use [OTEL]-specific metrics types *) type Trace.span += Span_otel of OTEL.Span.t type Trace.extension_event += @@ -21,6 +24,14 @@ end open Extensions +(* Inject ambient span into [Trace], relying on the [Ambient_context] + library. We use the generic ambient context to carry a [Hmap.t] around with + possible the current [Trace.span], and it is also used by [OTEL] itself + (ambient [OTEL.Span_ctx.t]). + + This mechanism is used by [Trace] so that nested [Trace.with_span] can infer + the correct parent-child relation from implicit context, and produce OTEL + spans accordingly; without it every span would be parentless. *) module Ambient_span_provider_ = struct let get_current_span () = match OTEL.Ambient_span.get () with