Skip to content

Commit 14dc69e

Browse files
documentation about runtime events
1 parent 84eb4c4 commit 14dc69e

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

src/core/lwt.mli

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2077,4 +2077,6 @@ module Private : sig
20772077
end
20782078
end [@@alert trespassing "for internal use only, keep away"]
20792079

2080+
(** [Lwt.with_key tracing_context (Some name) (fun () -> <e>)] causes the span
2081+
events emitted inside of <e> to bear the name [name]. *)
20802082
val tracing_context : string key

src/core/lwt_rte.mli

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
(** All the functions below are wrappers around the ones found in
2+
[Lwt_runtime_events]. The wrappers conditionally call the correspoding
3+
wrapped function or do nothing, depending if the [Lwt_runtime_events] library
4+
is available.
5+
6+
Note that [Lwt_runtime_events] is only installable with OCaml 5.1+ *)
7+
18
val emit_paused_count : int -> unit
29
val emit_sch_call_begin : unit -> unit
310
val emit_sch_call_end : unit -> unit

src/runtime_events/lwt_runtime_events.mli

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,28 @@
1+
(** This is the runtime-events library for lwt. It contains lwt-specific
2+
definition of events (so that programs can be written to consume the events
3+
lwt produces) and the function to emit them (so that lwt can emit them). This
4+
library is not intended for emitting events by hand. *)
5+
6+
(** Counter event indicatiing the number of paused promise, i.e., the number of
7+
calls to [Lwt.pause] which have not yet been resolved. *)
18
type Runtime_events.User.tag += Paused_count
29
val paused_count : int Runtime_events.User.t
310
val emit_paused_count : int -> unit
411

12+
(** Span event indicatiing that [Lwt_main.run] has been called and hasn't
13+
returned yet, i.e., when the Lwt scheduler is running. *)
514
type Runtime_events.User.tag += Scheduler_call
615
val sch_call : Runtime_events.Type.span Runtime_events.User.t
716
val emit_sch_call_begin : unit -> unit
817
val emit_sch_call_end : unit -> unit
918

19+
(** Punctual event indicatiing that the scheduler is performing one loop. *)
1020
type Runtime_events.User.tag += Scheduler_lap
1121
val sch_lap : unit Runtime_events.User.t
1222
val emit_sch_lap : unit -> unit
1323

24+
(** Counter event indicatiing the number of unix I/O jobs, i.e., the number of
25+
calls to [Lwt_unix.*] which have not yet been resolved. *)
1426
type Runtime_events.User.tag += Unix_job_count
1527
val unix_job_count : int Runtime_events.User.t
1628
val emit_job_count : int -> unit
@@ -19,6 +31,9 @@ module Trace : sig
1931
type t = { kind: Runtime_events.Type.span; context: string option; filename: string; line: int; }
2032
val t : t Runtime_events.Type.t
2133

34+
(** Span event indicatiing that a promise is taking time to resolve. The
35+
event indicates the location of the bind for the promise. These events are
36+
automatically emitted by code produced by the lwt_ppx syntax extension. *)
2237
type Runtime_events.User.tag += T
2338
val span : t Runtime_events.User.t
2439
val emit : t -> unit

0 commit comments

Comments
 (0)