From 2a2f3ea5b2d956c89f038e3798ee110c970173e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Wed, 18 Feb 2026 14:27:55 +0100 Subject: [PATCH 1/7] compatibility with lwt.6 --- devkit.opam | 3 ++- lwt_engines.ml | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/devkit.opam b/devkit.opam index 25301de..993f641 100644 --- a/devkit.opam +++ b/devkit.opam @@ -17,7 +17,8 @@ depends: [ "ounit2" "camlzip" "libevent" {>= "0.8.0"} - "ocurl" {>= "0.7.2"} + "curl" {>= "0.10.0"} + "curl_lwt" "pcre2" {>= "8.0.3"} "trace" {>= "0.4"} "extunix" {>= "0.1.4"} diff --git a/lwt_engines.ml b/lwt_engines.ml index 3802e29..9cf06c4 100644 --- a/lwt_engines.ml +++ b/lwt_engines.ml @@ -30,6 +30,8 @@ method poll fds timeout = l end +type Lwt_engine.engine_id += Engine_id__Devkit_libevent + (** libevent-based engine for lwt *) class libevent = let once_block = Ev.[ONCE] in @@ -37,6 +39,8 @@ let once_nonblock = Ev.[ONCE;NONBLOCK] in object(self) inherit Lwt_engine.abstract + method id = Engine_id__Devkit_libevent + val events_ = Ev.init () val mutable pid = Unix.getpid () method events = From 54f1db0f420290fb0d4dc6fd7a0673930282991e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Wed, 18 Feb 2026 14:47:38 +0100 Subject: [PATCH 2/7] engine selection is based on lwt reporting its engine --- prelude.ml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/prelude.ml b/prelude.ml index ec457e2..c13e44a 100644 --- a/prelude.ml +++ b/prelude.ml @@ -61,6 +61,13 @@ let call_me_maybe f x = and poll is guaranteed to be available without the fd limitation. *) let () = - if not (Lwt_config._HAVE_LIBEV && Lwt_config.libev_default) then begin + match Lwt_engine.id () with + | Lwt_engine.Engine_id__libev _ -> () + | Lwt_engine.Engine_id__select -> + (* Otherwise, prefer poll over select, because select can only monitor fds up to 1024, + and poll is guaranteed to be available without the fd limitation. *) Lwt_engine.set @@ new Lwt_engines.poll - end + | Lwt_engine.Engine_id__poll -> () + | lwteng -> + eprintfn "Unknown Lwt engine (%s) in use, leaving as is" Obj.Extension_constructor.(name (of_val lwteng)); + () From 2a212e10b050cad70f4d8f264116f5fb6044462c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Wed, 18 Feb 2026 15:20:29 +0100 Subject: [PATCH 3/7] incompatible with lwt<6 --- devkit.opam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devkit.opam b/devkit.opam index 993f641..687e423 100644 --- a/devkit.opam +++ b/devkit.opam @@ -22,7 +22,7 @@ depends: [ "pcre2" {>= "8.0.3"} "trace" {>= "0.4"} "extunix" {>= "0.1.4"} - "lwt" {>= "5.7.0"} + "lwt" {>= "6.0.0"} "lwt_ppx" "base-bytes" "base-unix" From fb1cd3de61e529614fea8d14b5d8e4de860abe11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Thu, 19 Feb 2026 10:59:01 +0100 Subject: [PATCH 4/7] compat with recent otel/trace --- devkit.opam | 2 +- possibly_otel.real.ml | 12 +++++++----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/devkit.opam b/devkit.opam index 687e423..f3becd3 100644 --- a/devkit.opam +++ b/devkit.opam @@ -20,7 +20,7 @@ depends: [ "curl" {>= "0.10.0"} "curl_lwt" "pcre2" {>= "8.0.3"} - "trace" {>= "0.4"} + "trace" {>= "0.10"} "extunix" {>= "0.1.4"} "lwt" {>= "6.0.0"} "lwt_ppx" diff --git a/possibly_otel.real.ml b/possibly_otel.real.ml index f56d67c..ab6ef73 100644 --- a/possibly_otel.real.ml +++ b/possibly_otel.real.ml @@ -8,7 +8,7 @@ module Traceparent = struct let get_ambient ?explicit_span () = let* Scope.{ trace_id; span_id; _ } = Scope.get_ambient_scope () in let span_id = match explicit_span with - | Some {Trace_core.span; _} -> Opentelemetry_trace.Internal.otel_of_otrace span + | Some {Trace_core.span; _} -> Opentelemetry_trace.Conv.span_id_to_otel span | None -> span_id in Trace_context.Traceparent.to_value ~trace_id ~parent_id:span_id () @@ -17,10 +17,12 @@ end let enter_manual_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name = match Scope.get_ambient_scope () with | None -> - Trace_core.enter_manual_toplevel_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name - | Some Scope.{ span_id; _ } -> + Trace_core.enter_manual_span ~parent:None ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name + | Some Scope.{ span_id; trace_id; _ } -> let otrace_espan = Trace_core.{ - span = Opentelemetry_trace.Internal.otrace_of_otel span_id; + span = Opentelemetry_trace.Conv.span_id_of_otel span_id; + trace_id = Opentelemetry_trace.Conv.trace_id_of_otel trace_id; meta = Trace_core.Meta_map.empty } in - Trace_core.enter_manual_sub_span ~parent:otrace_espan ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name + let parent = Some (Trace_core.ctx_of_span otrace_espan) in + Trace_core.enter_manual_span ~parent ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name From 11819a791df6f6f63e0d018e34d645ef16967595 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Thu, 26 Feb 2026 15:23:06 +0100 Subject: [PATCH 5/7] trace.0.11 has breaking deprecations and incompat with otel --- devkit.opam | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/devkit.opam b/devkit.opam index f3becd3..3543456 100644 --- a/devkit.opam +++ b/devkit.opam @@ -20,7 +20,7 @@ depends: [ "curl" {>= "0.10.0"} "curl_lwt" "pcre2" {>= "8.0.3"} - "trace" {>= "0.10"} + "trace" {>= "0.10" & < "0.11"} "extunix" {>= "0.1.4"} "lwt" {>= "6.0.0"} "lwt_ppx" From ab08bb1fbedbe87d184c9ba4b6f0f0adf4694e2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 27 Feb 2026 08:29:02 +0100 Subject: [PATCH 6/7] fix stub for when otel not installed --- possibly_otel.stub.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/possibly_otel.stub.ml b/possibly_otel.stub.ml index 2afe916..18f8d15 100644 --- a/possibly_otel.stub.ml +++ b/possibly_otel.stub.ml @@ -6,4 +6,4 @@ end let enter_manual_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name = - Trace_core.enter_manual_toplevel_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name + Trace_core.enter_manual_span ~parent:None ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name From de706370ebe12cc39a88db6aa40523a309d40fbb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Fri, 13 Mar 2026 14:52:30 +0100 Subject: [PATCH 7/7] trace.0.12 compat, but dirty by removing some actual tracing capabilitie --- devkit.opam | 2 +- possibly_otel.mli | 4 ++-- possibly_otel.real.ml | 18 ++---------------- web.ml | 4 ++-- 4 files changed, 7 insertions(+), 21 deletions(-) diff --git a/devkit.opam b/devkit.opam index 3543456..3708d79 100644 --- a/devkit.opam +++ b/devkit.opam @@ -20,7 +20,7 @@ depends: [ "curl" {>= "0.10.0"} "curl_lwt" "pcre2" {>= "8.0.3"} - "trace" {>= "0.10" & < "0.11"} + "trace" {>= "0.12"} "extunix" {>= "0.1.4"} "lwt" {>= "6.0.0"} "lwt_ppx" diff --git a/possibly_otel.mli b/possibly_otel.mli index d880365..5179fe9 100644 --- a/possibly_otel.mli +++ b/possibly_otel.mli @@ -2,7 +2,7 @@ module Otrace := Trace_core module Traceparent : sig val name : string - val get_ambient : ?explicit_span:Trace_core.explicit_span -> unit -> string option + val get_ambient : ?explicit_span:Trace_core.span -> unit -> string option end val enter_manual_span : @@ -11,4 +11,4 @@ val enter_manual_span : __LINE__:int -> ?data:(unit -> (string * Otrace.user_data) list) -> string -> - Trace_core.explicit_span + Trace_core.span diff --git a/possibly_otel.real.ml b/possibly_otel.real.ml index ab6ef73..50e6e7f 100644 --- a/possibly_otel.real.ml +++ b/possibly_otel.real.ml @@ -5,24 +5,10 @@ let (let*) o f = Option.map f o module Traceparent = struct let name = Trace_context.Traceparent.name - let get_ambient ?explicit_span () = + let get_ambient ?explicit_span:_ () = let* Scope.{ trace_id; span_id; _ } = Scope.get_ambient_scope () in - let span_id = match explicit_span with - | Some {Trace_core.span; _} -> Opentelemetry_trace.Conv.span_id_to_otel span - | None -> span_id - in Trace_context.Traceparent.to_value ~trace_id ~parent_id:span_id () end let enter_manual_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name = - match Scope.get_ambient_scope () with - | None -> - Trace_core.enter_manual_span ~parent:None ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name - | Some Scope.{ span_id; trace_id; _ } -> - let otrace_espan = Trace_core.{ - span = Opentelemetry_trace.Conv.span_id_of_otel span_id; - trace_id = Opentelemetry_trace.Conv.trace_id_of_otel trace_id; - meta = Trace_core.Meta_map.empty - } in - let parent = Some (Trace_core.ctx_of_span otrace_espan) in - Trace_core.enter_manual_span ~parent ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name + Trace_core.enter_span ~parent:None ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name diff --git a/web.ml b/web.ml index 9431236..da01ce0 100644 --- a/web.ml +++ b/web.ml @@ -321,8 +321,8 @@ module Http (IO : IO_TYPE) (Curl_IO : CURL with type 'a t = 'a IO.t) : HTTP with let t = new Action.timer in let result = Some (fun h code -> if verbose then verbose_curl_result nr_http action t h code; - Trace_core.add_data_to_manual_span explicit_span ["http.response.status_code", `Int (Curl.get_httpcode h)]; - Trace_core.exit_manual_span explicit_span; + Trace_core.add_data_to_span explicit_span ["http.response.status_code", `Int (Curl.get_httpcode h)]; + Trace_core.exit_span explicit_span; return () ) in