NVIDIA DeepStream SDK API Reference

8.0 Release
sources/includes/prometheus/family.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <memory>
4 #include <mutex>
5 #include <string>
6 #include <unordered_map>
7 #include <vector>
8 
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"
16 
17 // IWYU pragma: no_include "prometheus/counter.h"
18 // IWYU pragma: no_include "prometheus/gauge.h"
19 // IWYU pragma: no_include "prometheus/histogram.h"
20 // IWYU pragma: no_include "prometheus/info.h"
21 // IWYU pragma: no_include "prometheus/summary.h"
22 
23 namespace prometheus {
24 
61 template <typename T>
63  public:
92  Family(const std::string& name, const std::string& help,
93  const Labels& constant_labels);
94 
112  template <typename... Args>
113  T& Add(const Labels& labels, Args&&... args) {
114  return Add(labels, detail::make_unique<T>(args...));
115  }
116 
121  void Remove(T* metric);
122 
126  bool Has(const Labels& labels) const;
127 
131  const std::string& GetName() const;
132 
136  const Labels& GetConstantLabels() const;
137 
143  std::vector<MetricFamily> Collect() const override;
144 
145  private:
146  std::unordered_map<Labels, std::unique_ptr<T>, detail::LabelHasher> metrics_;
147 
148  const std::string name_;
149  const std::string help_;
150  const Labels constant_labels_;
151  mutable std::mutex mutex_;
152 
153  ClientMetric CollectMetric(const Labels& labels, T* metric) const;
154  T& Add(const Labels& labels, std::unique_ptr<T> object);
155 };
156 
157 } // 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::Family::Add
T & Add(const Labels &labels, Args &&... args)
Add a new dimensional data.
Definition: sources/includes/prometheus/family.h:113
prometheus::detail::LabelHasher
Label hasher for use in STL containers.
Definition: sources/includes/prometheus/detail/utils.h:12
prometheus::Labels
std::map< std::string, std::string > Labels
Multiple labels and their value.
Definition: sources/includes/prometheus/labels.h:9
prometheus::ClientMetric
Definition: sources/includes/prometheus/client_metric.h:12
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