6 #include <unordered_map>
9 #include "prometheus/client_metric.h"
10 #include "prometheus/collectable.h"
11 #include "prometheus/detail/core_export.h"
12 #include "prometheus/detail/future_std.h"
13 #include "prometheus/detail/utils.h"
14 #include "prometheus/labels.h"
15 #include "prometheus/metric_family.h"
22 namespace prometheus {
91 Family(
const std::string& name,
const std::string& help,
92 const Labels& constant_labels);
111 template <
typename... Args>
112 T&
Add(
const Labels& labels, Args&&... args) {
113 return Add(labels, detail::make_unique<T>(args...));
120 void Remove(T* metric);
125 bool Has(
const Labels& labels)
const;
130 const std::string& GetName()
const;
135 const Labels GetConstantLabels()
const;
142 std::vector<MetricFamily> Collect()
const override;
145 std::unordered_map<Labels, std::unique_ptr<T>, detail::LabelHasher> metrics_;
147 const std::string name_;
148 const std::string help_;
149 const Labels constant_labels_;
150 mutable std::mutex mutex_;
152 ClientMetric CollectMetric(
const Labels& labels, T* metric)
const;
153 T& Add(
const Labels& labels, std::unique_ptr<T>
object);
Interface implemented by anything that can be used by Prometheus to collect metrics.
Definition: collectable.h:17
A metric of type T with a set of labeled dimensions.
Definition: family.h:61
T & Add(const Labels &labels, Args &&... args)
Add a new dimensional data.
Definition: family.h:112
Definition: client_metric.h:12