Prometheus Client Library for Modern C++
Loading...
Searching...
No Matches
gauge.h
1#pragma once
2
3#include <atomic>
4
5#include "prometheus/client_metric.h"
6#include "prometheus/detail/builder.h" // IWYU pragma: export
7#include "prometheus/detail/core_export.h"
8#include "prometheus/metric_type.h"
9
10namespace prometheus {
11
24class PROMETHEUS_CPP_CORE_EXPORT Gauge {
25 public:
26 static const MetricType metric_type{MetricType::Gauge};
27
29 Gauge() = default;
30
32 explicit Gauge(double);
33
35 void Increment();
36
38 void Increment(double);
39
41 void Decrement();
42
44 void Decrement(double);
45
47 void Set(double);
48
50 void SetToCurrentTime();
51
53 double Value() const;
54
58 ClientMetric Collect() const;
59
60 private:
61 void Change(double);
62 std::atomic<double> value_{0.0};
63};
64
92PROMETHEUS_CPP_CORE_EXPORT detail::Builder<Gauge> BuildGauge();
93
94} // namespace prometheus
A gauge metric to represent a value that can arbitrarily go up and down.
Definition gauge.h:24
Gauge()=default
Create a gauge that starts at 0.
Definition client_metric.h:12