NVIDIA DeepStream SDK API Reference

8.0 Release
sources/includes/prometheus/registry.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <mutex>
5 #include <string>
6 #include <vector>
7 
8 #include "prometheus/collectable.h"
9 #include "prometheus/detail/core_export.h"
10 #include "prometheus/family.h"
11 #include "prometheus/labels.h"
12 #include "prometheus/metric_family.h"
13 
14 namespace prometheus {
15 
16 class Counter;
17 class Gauge;
18 class Histogram;
19 class Info;
20 class Summary;
21 
22 namespace detail {
23 
24 template <typename T>
25 class Builder; // IWYU pragma: keep
26 
27 }
42  public:
47  enum class InsertBehavior {
51  Merge,
53  Throw,
54  };
55 
59  explicit Registry(InsertBehavior insert_behavior = InsertBehavior::Merge);
60 
62  Registry(const Registry&) = delete;
63 
65  Registry& operator=(const Registry&) = delete;
66 
68  Registry(Registry&&) = delete;
69 
71  Registry& operator=(Registry&&) = delete;
72 
74  ~Registry() override;
75 
82  std::vector<MetricFamily> Collect() const override;
83 
94  template <typename T>
95  bool Remove(const Family<T>& family);
96 
97  private:
98  template <typename T>
99  friend class detail::Builder;
100 
101  template <typename T>
102  std::vector<std::unique_ptr<Family<T>>>& GetFamilies();
103 
104  template <typename T>
105  bool NameExistsInOtherType(const std::string& name) const;
106 
107  template <typename T>
108  Family<T>& Add(const std::string& name, const std::string& help,
109  const Labels& labels);
110 
111  const InsertBehavior insert_behavior_;
112  std::vector<std::unique_ptr<Family<Counter>>> counters_;
113  std::vector<std::unique_ptr<Family<Gauge>>> gauges_;
114  std::vector<std::unique_ptr<Family<Histogram>>> histograms_;
115  std::vector<std::unique_ptr<Family<Info>>> infos_;
116  std::vector<std::unique_ptr<Family<Summary>>> summaries_;
117  mutable std::mutex mutex_;
118 };
119 
120 } // namespace prometheus
prometheus::Collectable
Interface implemented by anything that can be used by Prometheus to collect metrics.
Definition: sources/includes/prometheus/collectable.h:17
prometheus::Family
A metric of type T with a set of labeled dimensions.
Definition: sources/includes/prometheus/family.h:62
prometheus::MetricType::Info
@ Info
prometheus::Registry::InsertBehavior
InsertBehavior
How to deal with repeatedly added family names for a type.
Definition: sources/includes/prometheus/registry.h:47
prometheus::Labels
std::map< std::string, std::string > Labels
Multiple labels and their value.
Definition: sources/includes/prometheus/labels.h:9
prometheus::MetricType::Histogram
@ Histogram
prometheus::MetricType::Gauge
@ Gauge
prometheus::Registry
Manages the collection of a number of metrics.
Definition: sources/includes/prometheus/registry.h:41
prometheus::detail::Builder
Definition: sources/includes/prometheus/registry.h:25
prometheus::MetricType::Counter
@ Counter
prometheus::MetricType::Summary
@ Summary
prometheus
Definition: sources/includes/prometheus/check_names.h:8
PROMETHEUS_CPP_CORE_EXPORT
#define PROMETHEUS_CPP_CORE_EXPORT
Definition: sources/includes/prometheus/detail/core_export.h:15