Loading...
Searching...
No Matches
registry.h
#pragma once
#include <memory>
#include <mutex>
#include <string>
#include <vector>
#include "prometheus/collectable.h"
#include "prometheus/detail/core_export.h"
#include "prometheus/family.h"
#include "prometheus/labels.h"
#include "prometheus/metric_family.h"
namespace prometheus {
class Counter;
class Gauge;
class Histogram;
class Summary;
namespace detail {
template <typename T>
class Builder; // IWYU pragma: keep
}
class PROMETHEUS_CPP_CORE_EXPORT Registry : public Collectable {
public:
enum class InsertBehavior {
Merge,
Throw,
};
explicit Registry(InsertBehavior insert_behavior = InsertBehavior::Merge);
Registry(const Registry&) = delete;
Registry& operator=(const Registry&) = delete;
Registry(Registry&&) = delete;
Registry& operator=(Registry&&) = delete;
~Registry() override;
std::vector<MetricFamily> Collect() const override;
template <typename T>
bool Remove(const Family<T>& family);
private:
template <typename T>
friend class detail::Builder;
template <typename T>
std::vector<std::unique_ptr<Family<T>>>& GetFamilies();
template <typename T>
bool NameExistsInOtherType(const std::string& name) const;
template <typename T>
Family<T>& Add(const std::string& name, const std::string& help,
const Labels& labels);
const InsertBehavior insert_behavior_;
std::vector<std::unique_ptr<Family<Counter>>> counters_;
std::vector<std::unique_ptr<Family<Gauge>>> gauges_;
std::vector<std::unique_ptr<Family<Histogram>>> histograms_;
std::vector<std::unique_ptr<Family<Summary>>> summaries_;
mutable std::mutex mutex_;
};
} // namespace prometheus
prometheus::Collectable
Interface implemented by anything that can be used by Prometheus to collect metrics.
Definition collectable.h:17
prometheus::Family
A metric of type T with a set of labeled dimensions.
Definition family.h:61
prometheus::Registry
Manages the collection of a number of metrics.
Definition registry.h:40
prometheus::Registry::operator=
Registry & operator=(Registry &&)=delete
Deleted move assignment.
prometheus::Registry::~Registry
~Registry() override
name Destroys a registry.
prometheus::Registry::Registry
Registry(const Registry &)=delete
Deleted copy constructor.
prometheus::Registry::Registry
Registry(Registry &&)=delete
Deleted move constructor.
prometheus::Registry::operator=
Registry & operator=(const Registry &)=delete
Deleted copy assignment.
prometheus::Registry::InsertBehavior
InsertBehavior
How to deal with repeatedly added family names for a type.
Definition registry.h:46