Prometheus Client Library for Modern C++
Loading...
Searching...
No Matches
histogram.h
1#pragma once
2
3#include <mutex>
4#include <vector>
5
6#include "prometheus/client_metric.h"
7#include "prometheus/counter.h"
8#include "prometheus/detail/builder.h" // IWYU pragma: export
9#include "prometheus/detail/core_export.h"
10#include "prometheus/gauge.h"
11#include "prometheus/metric_type.h"
12
13namespace prometheus {
14
31class PROMETHEUS_CPP_CORE_EXPORT Histogram {
32 public:
33 using BucketBoundaries = std::vector<double>;
34
35 static const MetricType metric_type{MetricType::Histogram};
36
47 explicit Histogram(const BucketBoundaries& buckets);
48
50 explicit Histogram(BucketBoundaries&& buckets);
51
58 void Observe(double value);
59
65 void ObserveMultiple(const std::vector<double>& bucket_increments,
66 double sum_of_values);
67
72 void Reset();
73
77 ClientMetric Collect() const;
78
79 private:
80 BucketBoundaries bucket_boundaries_;
81 mutable std::mutex mutex_;
82 std::vector<Counter> bucket_counts_;
83 Gauge sum_;
84};
85
113PROMETHEUS_CPP_CORE_EXPORT detail::Builder<Histogram> BuildHistogram();
114
115} // namespace prometheus
A gauge metric to represent a value that can arbitrarily go up and down.
Definition gauge.h:24
A histogram metric to represent aggregatable distributions of events.
Definition histogram.h:31
Definition client_metric.h:12