Page
Library
Module
Module type
Parameter
Class
Class type
Source
Metrics.SrcSourceMetric 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"fields 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.
duration t is true iff t is a fn source and t requires automatic duration recording.
status t is true iff t is a fn source and t requires automatic duration recording.