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.12"}
"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
4 changes: 2 additions & 2 deletions possibly_otel.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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 :
Expand All @@ -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
16 changes: 2 additions & 14 deletions possibly_otel.real.ml
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +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.Internal.otel_of_otrace 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_toplevel_span ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name
| Some Scope.{ span_id; _ } ->
let otrace_espan = Trace_core.{
span = Opentelemetry_trace.Internal.otrace_of_otel span_id;
meta = Trace_core.Meta_map.empty
} in
Trace_core.enter_manual_sub_span ~parent:otrace_espan ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name
Trace_core.enter_span ~parent:None ~__FUNCTION__ ~__FILE__ ~__LINE__ ?data name
2 changes: 1 addition & 1 deletion possibly_otel.stub.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this method not available in lwt 6?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is available

is the concern that then we don't have a version of devkit that's compatible with both 5.9 and 6 so it makes the upgrade for users more difficult? if that's the case then i have ocsigen/lwt#1106 in the works to allow specifically for that

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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see Obj i suspect
there is no name function to use?
but then anw i would rather emit log for non-default behaviour branch (ie select=>poll) and do not log anything in other branches (ie here)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i can make that change

()
4 changes: 2 additions & 2 deletions web.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down