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 friend bool operator<(const Label& lhs, const Label& rhs) {
20 return std::tie(lhs.name, lhs.value) < std::tie(rhs.name, rhs.value);
21 }
22
23 friend bool operator==(const Label& lhs, const Label& rhs) {
24 return std::tie(lhs.name, lhs.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 // Info
44
45 struct Info {
46 double value = 1.0;
47 };
48 Info info;
49
50 // Summary
51
52 struct Quantile {
53 double quantile = 0.0;
54 double value = 0.0;
55 };
56
57 struct Summary {
58 std::uint64_t sample_count = 0;
59 double sample_sum = 0.0;
60 std::vector<Quantile> quantile;
61 };
62 Summary summary;
63
64 // Histogram
65
66 struct Bucket {
67 std::uint64_t cumulative_count = 0;
68 double upper_bound = 0.0;
69 };
70
71 struct Histogram {
72 std::uint64_t sample_count = 0;
73 double sample_sum = 0.0;
74 std::vector<Bucket> bucket;
75 };
76 Histogram histogram;
77
78 // Untyped
79
80 struct Untyped {
81 double value = 0;
82 };
83 Untyped untyped;
84
85 // Timestamp
86
87 std::int64_t timestamp_ms = 0;
88};
89
90} // namespace prometheus
Definition client_metric.h:66
Definition client_metric.h:31
Definition client_metric.h:38
Definition client_metric.h:71
Definition client_metric.h:45
Definition client_metric.h:15
Definition client_metric.h:52
Definition client_metric.h:57
Definition client_metric.h:80
Definition client_metric.h:12