.\" -*- mode: troff; coding: utf-8 -*- .\" Automatically generated by Pod::Man 5.01 (Pod::Simple 3.43) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>. .ie n \{\ . ds C` "" . ds C' "" 'br\} .el\{\ . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Net::Prometheus::Metric 3pm" .TH Net::Prometheus::Metric 3pm 2024-03-07 "perl v5.38.2" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH NAME "Net::Prometheus::Metric" \- the base class for observed metrics .SH DESCRIPTION .IX Header "DESCRIPTION" This class provides the basic methods shared by the concrete subclasses, .IP \(bu 2 Net::Prometheus::Gauge \- a snapshot value-reporting metric .IP \(bu 2 Net::Prometheus::Counter \- a monotonically-increasing counter metric .IP \(bu 2 Net::Prometheus::Summary \- summarise individual numeric observations .IP \(bu 2 Net::Prometheus::Histogram \- count the distribution of numeric observations .SH CONSTRUCTOR .IX Header "CONSTRUCTOR" .SS new .IX Subsection "new" .Vb 4 \& $metric = Net::Prometheus::Metric\->new( \& name => $name, \& help => $help, \& ) .Ve .PP The constructor is not normally used directly by instrumented code. Instead it is more common to use one of the \f(CW\*(C`new_*\*(C'\fR methods on the containing Net::Prometheus client instance so that the new metric is automatically registered as a collector, and gets exported by the render method. .PP .Vb 4 \& $metric = $prometheus\->new_counter( \& name => $name, \& help => $help, \& ) .Ve .PP In either case, it returns a newly-constructed metric. .PP Takes the following named arguments: .IP "namespace => STR" 4 .IX Item "namespace => STR" .PD 0 .IP "subsystem => STR" 4 .IX Item "subsystem => STR" .PD Optional strings giving the namespace and subsystem name parts of the variable name. .IP "name => STR" 4 .IX Item "name => STR" The basename of the exported variable. .IP "help => STR" 4 .IX Item "help => STR" Descriptive help text for the variable. .IP "labels => ARRAY of STR" 4 .IX Item "labels => ARRAY of STR" Optional ARRAY reference giving the names of labels for the metric. .SH METHODS .IX Header "METHODS" .SS fullname .IX Subsection "fullname" .Vb 1 \& $fullname = $metric\->fullname .Ve .PP Returns the full name for the metric. This is formed by joining any of the defined values for \f(CW\*(C`namespace\*(C'\fR, \f(CW\*(C`subsystem\*(C'\fR and \f(CW\*(C`name\*(C'\fR with \f(CW\*(Aq_\*(Aq\fR. .SS labelcount .IX Subsection "labelcount" .Vb 1 \& $labels = $metric\->labelcount .Ve .PP Returns the number of labels defined for this metric. .SS labels .IX Subsection "labels" .Vb 1 \& $child = $metric\->labels( @values ) \& \& $child = $metric\->labels( { name => $value, name => $value, ... } ) .Ve .PP Returns a child metric to represent the general one with the given set of labels. The label values may be provided either in a list corresponding to the list of label names given at construction time, or by name in a single HASH reference. .PP The child instance supports the same methods to control the value of the reported metric as the parent metric object, except that any label values are already provided. .PP This object may be cached for efficiency. .SS make_sample .IX Subsection "make_sample" .Vb 1 \& $sample = $metric\->make_sample( $suffix, $labelkey, $value, $extralabels ) .Ve .PP Returns a new "Sample" in Net::Prometheus::Types structure to represent the given value, by expanding the opaque \f(CW$labelkey\fR value into its actual label names and values and appending the given suffix (which may be an empty string) to the metric's fullname. If provided, the suffix will be separated by an underscore \f(CW\*(Aq_\*(Aq\fR. If provided, \f(CW$extralabels\fR provides more label names and values to be added to the sample. .SS samples .IX Subsection "samples" .Vb 1 \& @samples = $metric\->samples .Ve .PP An abstract method in this class, this method is intended to be overridden by subclasses. .PP Called during the value collection process, this method should return a list of "Sample" in Net::Prometheus::Types instances containing the values to report from this metric. .SH AUTHOR .IX Header "AUTHOR" Paul Evans