NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/includes/prometheus/registry.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #pragma once
19 
20 #include <memory>
21 #include <mutex>
22 #include <string>
23 #include <vector>
24 
25 #include "prometheus/collectable.h"
26 #include "prometheus/detail/core_export.h"
27 #include "prometheus/family.h"
28 #include "prometheus/labels.h"
29 #include "prometheus/metric_family.h"
30 
31 namespace prometheus {
32 
33 class Counter;
34 class Gauge;
35 class Histogram;
36 class Info;
37 class Summary;
38 
39 namespace detail {
40 
41 template <typename T>
42 class Builder; // IWYU pragma: keep
43 
44 }
58 class PROMETHEUS_CPP_CORE_EXPORT Registry : public Collectable {
59  public:
64  enum class InsertBehavior {
68  Merge,
70  Throw,
71  };
72 
76  explicit Registry(InsertBehavior insert_behavior = InsertBehavior::Merge);
77 
79  Registry(const Registry&) = delete;
80 
82  Registry& operator=(const Registry&) = delete;
83 
85  Registry(Registry&&) = delete;
86 
88  Registry& operator=(Registry&&) = delete;
89 
91  ~Registry() override;
92 
99  std::vector<MetricFamily> Collect() const override;
100 
111  template <typename T>
112  bool Remove(const Family<T>& family);
113 
114  private:
115  template <typename T>
116  friend class detail::Builder;
117 
118  template <typename T>
119  std::vector<std::unique_ptr<Family<T>>>& GetFamilies();
120 
121  template <typename T>
122  bool NameExistsInOtherType(const std::string& name) const;
123 
124  template <typename T>
125  Family<T>& Add(const std::string& name, const std::string& help,
126  const Labels& labels);
127 
128  const InsertBehavior insert_behavior_;
129  std::vector<std::unique_ptr<Family<Counter>>> counters_;
130  std::vector<std::unique_ptr<Family<Gauge>>> gauges_;
131  std::vector<std::unique_ptr<Family<Histogram>>> histograms_;
132  std::vector<std::unique_ptr<Family<Info>>> infos_;
133  std::vector<std::unique_ptr<Family<Summary>>> summaries_;
134  mutable std::mutex mutex_;
135 };
136 
137 } // namespace prometheus
prometheus::Family
A metric of type T with a set of labeled dimensions.
Definition: includes/prometheus/family.h:79
prometheus::Registry::InsertBehavior
InsertBehavior
How to deal with repeatedly added family names for a type.
Definition: includes/prometheus/registry.h:64
prometheus::Labels
std::map< std::string, std::string > Labels
Multiple labels and their value.
Definition: includes/prometheus/labels.h:26
PROMETHEUS_CPP_CORE_EXPORT
#define PROMETHEUS_CPP_CORE_EXPORT
Definition: includes/prometheus/detail/core_export.h:31
prometheus::MetricType::Histogram
@ Histogram
sdk::common::internal_log::LogLevel::Info
@ Info
prometheus::MetricType::Gauge
@ Gauge
prometheus::Registry
Manages the collection of a number of metrics.
Definition: includes/prometheus/registry.h:58
prometheus::detail::Builder
Definition: includes/prometheus/registry.h:42
prometheus::MetricType::Counter
@ Counter
prometheus::MetricType::Summary
@ Summary
prometheus
Definition: includes/prometheus/check_names.h:25