NVIDIA DeepStream SDK API Reference

9.2 Release
includes/prometheus/histogram.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 <mutex>
21 #include <vector>
22 
23 #include "prometheus/client_metric.h"
24 #include "prometheus/counter.h"
25 #include "prometheus/detail/builder.h" // IWYU pragma: export
26 #include "prometheus/detail/core_export.h"
27 #include "prometheus/gauge.h"
28 #include "prometheus/metric_type.h"
29 
30 namespace prometheus {
31 
49  public:
50  using BucketBoundaries = std::vector<double>;
51 
52  static const MetricType metric_type{MetricType::Histogram};
53 
64  explicit Histogram(const BucketBoundaries& buckets);
65 
67  explicit Histogram(BucketBoundaries&& buckets);
68 
75  void Observe(double value);
76 
82  void ObserveMultiple(const std::vector<double>& bucket_increments,
83  double sum_of_values);
84 
89  void Reset();
90 
94  ClientMetric Collect() const;
95 
96  private:
97  BucketBoundaries bucket_boundaries_;
98  mutable std::mutex mutex_;
99  std::vector<Counter> bucket_counts_;
100  Gauge sum_;
101 };
102 
130 PROMETHEUS_CPP_CORE_EXPORT detail::Builder<Histogram> BuildHistogram();
131 
132 } // namespace prometheus
prometheus::Histogram
A histogram metric to represent aggregatable distributions of events.
Definition: includes/prometheus/histogram.h:48
prometheus::ClientMetric
Definition: includes/prometheus/client_metric.h:29
PROMETHEUS_CPP_CORE_EXPORT
#define PROMETHEUS_CPP_CORE_EXPORT
Definition: includes/prometheus/detail/core_export.h:31
prometheus::MetricType::Histogram
@ Histogram
prometheus::BuildHistogram
PROMETHEUS_CPP_CORE_EXPORT detail::Builder< Histogram > BuildHistogram()
Return a builder to configure and register a Histogram metric.
prometheus::MetricType
MetricType
Definition: includes/prometheus/metric_type.h:22
prometheus::Histogram::BucketBoundaries
std::vector< double > BucketBoundaries
Definition: includes/prometheus/histogram.h:50
prometheus::Gauge
A gauge metric to represent a value that can arbitrarily go up and down.
Definition: includes/prometheus/gauge.h:41
prometheus
Definition: includes/prometheus/check_names.h:25