class Registry

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


The metric registry is a collection of all active Collector instances.

The Registry internally stores plain pointers to Collector objects. 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.

Member Summary

Member Functions: clear, defaultRegistry, exportTo, findCollector, registerCollector, unregisterCollector



Registry() = default;

Creates the Registry.



~Registry() = default;

Destroys the Registry.

Member Functions


void clear();

Removes all Collector instances from the Registry.

defaultRegistry static

static Registry & defaultRegistry();

Returns the default Registry.


void exportTo(
    Exporter & exporter
) const;

Exports all registered collector's metrics through the given Exporter.


Collector * findCollector(
    const std::string & collectorName
) const;

Looks up the Collector with the given name.

Returns a pointer to the collector instance if found, otherwise returns a nullptr.


void registerCollector(
    Collector * pCollector

Registers a Collector with the Registry.

An attempt to register a collector with the name of an already registered collector will fail with a Poco::ExistsException.


void unregisterCollector(
    Collector * pCollector

Removes a Collector from the Registry.


void unregisterCollector(
    const std::string & collectorName

Removes the Collector with the given name from the Registry.

Does nothing if no collector with the given name has been registered.