package catapult

  1. Overview
  2. Docs

Profiling probes.

This is the main API. The user can insert probes into their code, and at runtime, these probes will use the Backend (if present) to emit tracing events to be replayed later. If no backend is present, the probes will do nothing.

type backend = (module Catapult__.Backend.S)
type arg = [
  1. | `Int of int
  2. | `String of string
  3. | `Float of float
  4. | `Bool of bool
  5. | `Null
]
type 'a emit_fun_base = ?pid:int -> ?tid:int -> ?args:(string * arg) list -> string -> 'a

Emitter function, without timestamp. See emit_fun for more details.

type 'a with_cat = ?cat:string list -> 'a
type 'a with_ts_us = ?ts_us:float -> 'a
type 'a with_stack = ?stack:string list -> 'a

Function that can take a stack trace

type 'a emit_fun = 'a emit_fun_base with_cat with_ts_us

An emitter function. The positional string argument is the name.

  • parameter cat

    list of categories for filtering the event

  • parameter pid

    the process ID

  • parameter tid

    the thread ID

  • parameter arguments

    list of arguments for the event, with a name for each

  • parameter ts_us

    timestamp in microseconds

  • parameter name

    the name of this event

type span_start

Represents the beginning of a span, to emit compact spans

val null_span : span_start
val enabled : unit -> bool

Is tracing enabled?

val emit : (?dur:float -> Event_type.t -> unit) emit_fun with_stack

Emit a generic event.

val begin_ : unit -> span_start

Emit a "X" event with duration computed from the given span start

val with_ : ((unit -> 'a) -> 'a) emit_fun_base with_cat
val with1 : (('a -> 'b) -> 'a -> 'b) emit_fun_base with_cat
val with2 : (('a -> 'b -> 'c) -> 'a -> 'b -> 'c) emit_fun_base with_cat
val with3 : (('a -> 'b -> 'c -> 'd) -> 'a -> 'b -> 'c -> 'd) emit_fun_base with_cat
val begin' : unit emit_fun with_stack

Emit a "B" event

val exit' : unit emit_fun with_stack

Emit a "E" event

val span : (dur:float -> unit) emit_fun with_stack

Emit a "X" event

val obj_new : (id:string -> unit) emit_fun with_stack
val obj_snap : (snapshot:string -> id:string -> unit) emit_fun with_stack
val obj_delete : (id:string -> unit) emit_fun with_stack
val obj_with : (id:string -> (unit -> 'a) -> 'a) emit_fun
val obj_with1 : (id:string -> ('a -> 'b) -> 'a -> 'b) emit_fun
val a_begin : (cat:string list -> id:string -> unit) emit_fun_base with_ts_us
val a_exit : (cat:string list -> id:string -> unit) emit_fun_base with_ts_us
val a_snap : (cat:string list -> id:string -> unit) emit_fun_base with_ts_us
val a_with : (cat:string list -> id:string -> (unit -> 'a) -> 'a) emit_fun_base with_ts_us
val a_with1 : (cat:string list -> id:string -> ('a -> 'b) -> 'a -> 'b) emit_fun_base with_ts_us
val f_begin : (id:string -> unit) emit_fun
val f_exit : (id:string -> unit) emit_fun
val f_step : (id:string -> unit) emit_fun
val instant : unit emit_fun with_stack
val counter : (cs:(string * int) list -> unit) emit_fun
val meta_thread_name : string -> unit
val meta_process_name : string -> unit
val tick : unit -> unit

Depending on the tracing backend, this needs to be called regularly to ensure background work is done.

module Syntax : sig ... end
include module type of Syntax
val let@ : ('a -> 'b) -> 'a -> 'b
module Control : sig ... end

Controls the current backend.

OCaml

Innovation. Community. Security.