Poco::Prometheus

class Collector

File Information

Library: Prometheus
Package: Core
Header: Poco/Prometheus/Collector.h

Description

This is the base class for all metrics, such as Counter, Gauge and Histogram.

Collector objects automatically register themselves with the default Registry (unless a nullptr is passed to the constructor's pRegistry parameter), but do not automatically unregister. This brings the danger of dangling pointers if Collector instances are destroyed without being explicitly unregistered first. In most practical cases this is not an issue as Collector instances will be alive for the entire run time of the process. However, it can be an issue if Collector instances are created and destroyed dynamically during the run time of the process.

Inheritance

Known Derived Classes: ProcessCollector, CallbackMetric, LabeledMetric, IntCounter, IntGauge, ThreadPoolCollector, Metric, LabeledMetricImpl

Member Summary

Member Functions: exportTo, name, validateName

Constructors

Collector protected inline

Collector(
    const std::string & name
);

Creates a Collector with the given name and registers it with the default Registry.

The name must be a valid metric name and match the regular expression [a-zA-Z_:][a-zA-Z0-9_:]*.

Collector protected

Collector(
    const std::string & name,
    Registry * pRegistry
);

Creates a Collector with the given name and registers it with the given Registry (if not nullptr).

The name must be a valid metric name and match the regular expression [a-zA-Z_:][a-zA-Z0-9_:]*.

Destructor

~Collector virtual

virtual ~Collector() = default;

Destroys the Collector.

Member Functions

exportTo virtual

virtual void exportTo(
    Exporter & exporter
) const = 0;

Writes the given Metric to the Exporter.

name inline

const std::string & name() const;

Returns the metric's name.

validateName protected static

static const std::string & validateName(
    const std::string & name
);

Securely control IoT edge devices from anywhere   Connect a Device