Sources
val v : ?doc:string -> ?duration:bool -> ?status:bool -> tags:'a Tags.t -> data:'b -> string -> ('a, 'b) srcv ?doc ~tags name is a new source, accepting arbitrary data points. name is the name of the source; it doesn't need to be unique but it is good practice to prefix the name with the name of your package or library (e.g. "mypkg.network"). doc is a documentation string describing the source, defaults to "undocumented". tags is the collection if (typed) tags which will be used to tag and index the measure and are used identify the various metrics. The source will be enabled on creation iff one of tag in tags has been enabled with enable_tag.
For instance, to create a metric to collect CPU and memory usage on various machines, indexed by PID, host name and IP address:
let src =
let ipaddr = Tags.v Ipaddr.pp_hum in
let tags = Tags.[string "host"; ipaddr "IP" ; int "PID" ; ] in
let data () = Data.v [float "%CPU" (...); int "MEM" (...); ] in
Src.v "top" ~tags ~data ~doc:"Information about processess"Listing Sources
val list : unit -> t listlist () is the current exisiting source list.
val name : t -> stringname src is src's name.
val doc : t -> stringdoc src is src's documentation string.
val tags : t -> string listtags src is the list of src's tag names.
val data : t -> string listfields src is the list of src's data field names. Note that these are updated dynamically, so a monitoring function has to be called first.
val duration : t -> boolduration t is true iff t is a fn source and t requires automatic duration recording.
val status : t -> boolstatus t is true iff t is a fn source and t requires automatic duration recording.
val is_active : t -> boolis_active t is true iff t is enabled.
val enable : t -> unitenable src enables the metric source src.
val disable : t -> unitdisable src disables the metric source src.