Prometheus Client Library for Modern C++
Loading...
Searching...
No Matches
client_metric.h
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <tuple>
6#include <vector>
7
8#include "prometheus/detail/core_export.h"
9
10namespace prometheus {
11
12struct PROMETHEUS_CPP_CORE_EXPORT ClientMetric {
13 // Label
14
15 struct Label {
16 std::string name;
17 std::string value;
18
19 bool operator<(const Label& rhs) const {
20 return std::tie(name, value) < std::tie(rhs.name, rhs.value);
21 }
22
23 bool operator==(const Label& rhs) const {
24 return std::tie(name, value) == std::tie(rhs.name, rhs.value);
25 }
26 };
27 std::vector<Label> label;
28
29 // Counter
30
31 struct Counter {
32 double value = 0.0;
33 };
34 Counter counter;
35
36 // Gauge
37
38 struct Gauge {
39 double value = 0.0;
40 };
41 Gauge gauge;
42
43 // Summary
44
45 struct Quantile {
46 double quantile = 0.0;
47 double value = 0.0;
48 };
49
50 struct Summary {
51 std::uint64_t sample_count = 0;
52 double sample_sum = 0.0;
53 std::vector<Quantile> quantile;
54 };
55 Summary summary;
56
57 // Histogram
58
59 struct Bucket {
60 std::uint64_t cumulative_count = 0;
61 double upper_bound = 0.0;
62 };
63
64 struct Histogram {
65 std::uint64_t sample_count = 0;
66 double sample_sum = 0.0;
67 std::vector<Bucket> bucket;
68 };
69 Histogram histogram;
70
71 // Untyped
72
73 struct Untyped {
74 double value = 0;
75 };
76 Untyped untyped;
77
78 // Timestamp
79
80 std::int64_t timestamp_ms = 0;
81};
82
83} // namespace prometheus
Definition client_metric.h:59
Definition client_metric.h:31
Definition client_metric.h:38
Definition client_metric.h:64
Definition client_metric.h:15
Definition client_metric.h:45
Definition client_metric.h:50
Definition client_metric.h:73
Definition client_metric.h:12