123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167(** Callbacks used for subscribers.
Each subscriber defines a set of callbacks, for each possible tracing event.
These callbacks take a custom state that is paired with the callbacks in
{!Subscriber.t}.
To use a default implementation for some callbacks, use:
{[
module My_callbacks = struct
type st = …
include Trace_subscriber.Callbacks.Dummy
let on_init (state:st) ~time_ns : unit = …
(* … other custom callbacks … *)
end
]}
{b NOTE}: the [trace_id] passed alongside manual spans is guaranteed to be
at least 64 bits. *)openTrace_coreopenTypes(** First class module signature for callbacks *)moduletypeS=sigtypest(** Type of the state passed to every callback. *)valon_init:st->time_ns:int64->unit(** Called when the subscriber is initialized in a collector *)valon_shutdown:st->time_ns:int64->unit(** Called when the collector is shutdown *)valon_name_thread:st->time_ns:int64->tid:int->name:string->unit(** Current thread is being named *)valon_name_process:st->time_ns:int64->tid:int->name:string->unit(** Current process is being named *)valon_enter_span:st->__FUNCTION__:stringoption->__FILE__:string->__LINE__:int->time_ns:int64->tid:int->data:(string*user_data)list->name:string->span->unit(** Enter a regular (sync) span *)valon_exit_span:st->time_ns:int64->tid:int->span->unit(** Exit a span. This and [on_enter_span] must follow strict stack discipline
*)valon_add_data:st->data:(string*user_data)list->span->unit(** Add data to a regular span (which must be active) *)valon_message:st->time_ns:int64->tid:int->span:spanoption->data:(string*user_data)list->string->unit(** Emit a log message *)valon_counter:st->time_ns:int64->tid:int->data:(string*user_data)list->name:string->float->unit(** Emit the current value of a counter *)valon_enter_manual_span:st->__FUNCTION__:stringoption->__FILE__:string->__LINE__:int->time_ns:int64->tid:int->parent:spanoption->data:(string*user_data)list->name:string->flavor:flavoroption->trace_id:trace_id->span->unit(** Enter a manual (possibly async) span *)valon_exit_manual_span:st->time_ns:int64->tid:int->name:string->data:(string*user_data)list->flavor:flavoroption->trace_id:trace_id->span->unit(** Exit a manual span *)valon_extension_event:st->time_ns:int64->tid:int->extension_event->unit(** Extension event
@since 0.8 *)endtype'stt=(moduleSwithtypest='st)(** Callbacks for a subscriber. There is one callback per event in {!Trace}. The
type ['st] is the state that is passed to every single callback. *)(** Dummy callbacks. It can be useful to reuse some of these functions in a real
subscriber that doesn't want to handle {b all} events, but only some of
them.
To write a subscriber that only supports some callbacks, this can be handy:
{[
module My_callbacks = struct
type st = my_own_state
include Callbacks.Dummy
let on_counter (st:st) ~time_ns ~tid ~data ~name v : unit = ...
end
]} *)moduleDummy=structleton_init_~time_ns:_=()leton_shutdown_~time_ns:_=()leton_name_thread_~time_ns:_~tid:_~name:_=()leton_name_process_~time_ns:_~tid:_~name:_=()leton_message_~time_ns:_~tid:_~span:_~data:__msg=()leton_counter_~time_ns:_~tid:_~data:_~name:__v=()leton_enter_span_~__FUNCTION__:_~__FILE__:_~__LINE__:_~time_ns:_~tid:_~data:_~name:__sp=()leton_exit_span_~time_ns:_~tid:__=()leton_add_data_~data:__sp=()leton_enter_manual_span_~__FUNCTION__:_~__FILE__:_~__LINE__:_~time_ns:_~tid:_~parent:_~data:_~name:_~flavor:_~trace_id:__sp=()leton_exit_manual_span_~time_ns:_~tid:_~name:_~data:_~flavor:_~trace_id:__=()leton_extension_event_~time_ns:_~tid:__=()end(** Dummy callbacks, ignores all events. *)letdummy(typest)():stt=letmoduleM=structtypenonrecst=stincludeDummyendin(moduleM)