Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions devkit.opam
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,12 @@ depends: [
"ounit2"
"camlzip"
"libevent" {>= "0.8.0"}
"ocurl" {>= "0.7.2"}
"curl" {>= "0.10.0"}
"curl_lwt"
"pcre2" {>= "8.0.3"}
"trace" {>= "0.4"}
"trace" {>= "0.10"}
"extunix" {>= "0.1.4"}
"lwt" {>= "5.7.0"}
"lwt" {>= "6.0.0"}
"lwt_ppx"
"base-bytes"
"base-unix"
Expand Down
4 changes: 4 additions & 0 deletions lwt_engines.ml
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ 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
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 =
Expand Down
12 changes: 7 additions & 5 deletions possibly_otel.real.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand All @@ -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
11 changes: 9 additions & 2 deletions prelude.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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));
()