NAME
Net::Prometheus::Metric
- the base class for observed metrics
DESCRIPTION
This class provides the basic methods shared by the concrete subclasses,
CONSTRUCTOR
new
$metric = Net::Prometheus::Metric->new(
name => $name,
help => $help,
)
The constructor is not normally used directly by instrumented code. Instead it is more common to use one of the new_*
methods on the containing Net::Prometheus client instance.
$metric = $prometheus->new_counter(
name => $name,
help => $help,
)
In either case, it returns a newly-constructed metric.
Takes the following named arguments:
- namespace => STR
- subsystem => STR
-
Optional strings giving the namespace and subsystem name parts of the variable name.
- name => STR
-
The basename of the exported variable.
- help => STR
-
Descriptive help text for the variable.
- labels => ARRAY of STR
-
Optional ARRAY reference giving the names of labels for the metric.
METHODS
fullname
$fullname = $metric->fullname
Returns the full name for the metric. This is formed by joining any of the defined values for namespace
, subsystem
and name
with '_'
.
labelcount
$labels = $metric->labelcount
Returns the number of labels defined for this metric.
labels
$child = $metric->labels( @values )
Returns a child metric to represent the general one with the given set of labels. This object may be cached for efficiency.
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.
make_sample
$sample = $metric->make_sample( $suffix, $labelkey, $value )
Returns a new "Sample" in Net::Prometheus::Types structure to represent the given value, by expanding the opaque $labelkey
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 '_'
.
samples
@samples = $metric->samples
An abstract method in this class, this method is intended to be overriden by subclasses.
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.
AUTHOR
Paul Evans <leonerd@leonerd.org.uk>