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 Histogram(const BucketBoundaries& buckets);
48
55 void Observe(double value);
56
62 void ObserveMultiple(const std::vector<double>& bucket_increments,
63 const double sum_of_values);
64
68 ClientMetric Collect() const;
69
70 private:
71 const BucketBoundaries bucket_boundaries_;
72 mutable std::mutex mutex_;
73 std::vector<Counter> bucket_counts_;
74 Gauge sum_;
75};
76
104PROMETHEUS_CPP_CORE_EXPORT detail::Builder<Histogram> BuildHistogram();
105
106} // 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