GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Metrics::Any::AdapterBase::Stored(3) User Contributed Perl Documentation Metrics::Any::AdapterBase::Stored(3)

"Metrics::Any::AdapterBase::Stored" - a base class for metrics adapters which store values

This base class assists in creating Metrics::Any::Adapter classes which store values of reported metrics directly. These can then be retrieved later by the containing application, or the subclass code, by using the "walk" method.

This base class internally stores counter and gauge metrics as single scalar values directly. In order to provide flexibility for a variety of use-cases, it requires assistance from the implementing class on how to store distribution and timer metrics. The implementing class should provide these methods, returning whatever values it wishes to implement them with. These values are stored by the base class, and handed back as part of the "walk" method.

The base class stores a value for each unique set of labels and values on every metric; the subclass does not need to handle this.

   $stored->walk( $code )

      $code->( $type, $name, $labels, $value )

Given a CODE reference, this method invokes it once per labelset of every stored metric.

For each labelset, $type will give the metric type (as a string, either "counter", "distribution", "gauge" or "timer"), $name gives the name it was registered with, $labels will be a reference to an even-sized array containing label names and values.

For counter and gauge metrics, $value will be a numerical scalar giving the current value. For distribution and timer metrics, $value will be whatever the implementing class's corresponding "store_distribution" or "store_timer" method returns for them.

   $stored->clear_values

Clears all of the metric storage. Every labelset of every metric is deleted. The metric definitions themselves remain.

   $storage = $stored->store_distribution( $storage, $amount )

   $storage = $stored->store_timer( $storage, $duration )

The implementing class must provide these two methods to assist in the management of storage for distribution and timer metrics.

When a new observation for the metric is required, the method will be invoked, passing in the currently-stored perl value for the given metric and label values, and the new observation. Whatever the method returns is stored by the base class, to be passed in next time or used by the "walk" method.

The base class stores this value directly and does not otherwise interact with it; letting the implementing class decide what is best. For example, a simple implementation may just store every observation individually by pushing them into an array; so the $storage would be an ARRAY reference:

   sub store_distribution
   {
      my $self = shift;
      my ( $storage, $amount ) = @_;

      push @$storage, $amount;

      return $storage;
   }

Paul Evans <leonerd@leonerd.org.uk>
2022-04-07 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.