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(3) User Contributed Perl Documentation Metrics::Any(3)

"Metrics::Any" - abstract collection of monitoring metrics

In a module:

   use Metrics::Any '$metrics',
      strict => 0,
      name_prefix => [ 'my_module_name' ];

   sub do_thing {
      $metrics->inc_counter( 'things_done' );
   }

In a program or top-level program-like module:

   use Metrics::Any::Adapter 'Prometheus';

Provides a central location for modules to report monitoring metrics, such as counters of the number of times interesting events have happened, and programs to collect up and send those metrics to monitoring services.

Inspired by Log::Any, this module splits the overall problem into two sides. Modules wishing to provide metrics for monitoring purposes can use the "use Metrics::Any" statement to obtain a collector into which they can report metric events. By default this collector doesn't actually do anything, so modules can easily use it without adding extra specific dependencies for specific reporting.

A program using one or more such modules can apply a different policy and request a particular adapter implementation in order to actually report these metrics to some external system, by using the "use Metrics::Any::Adapter" statement.

This separation of concerns allows module authors to write code which will report metrics without needing to care about the exact mechanism of that reporting (as well as to write code which does not itself depend on the code required to perform that reporting).

At present this interface is in an early state of experimentation. The API is fairly specifically-shaped for Net::Prometheus at present, but it is hoped with more adapter implementations (such as for statsd or OpenTelemetry) the API shapes can be expanded and made more generic to support a wider variety of reporting mechanisms.

As a result, any API details for now should be considered experimental and subject to change in later versions.

For a module to use this facility, the "use" statement importing it should give the name of a variable (as a plain string) to store the collector for that package.

   use Metrics::Any '$metrics';

This variable will be created in the calling package and populated with an instance of Metrics::Any::Collector. The module can then use the collector API to declare new metrics, and eventually report values into them.

Note that the variable is created at the package level; any other packages within the same file will not see it and will have to declare their own.

  • The name and overall concept of this module is heavily influenced by a similar module for logging, Log::Any.
  • For reporting metrics to one specific target collector, there are specific modules for systems like statsd (Net::Statsd, Net::Async::Statsd) or prometheus (Prometheus::Tiny, Net::Prometheus).
  • There is also a similar concept in Measure::Everything.

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.