12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #pragma once
- #include <cstdint>
- #include <string>
- #include <tuple>
- #include <vector>
- namespace prometheus {
- // ñòðóêòóðà, â êîòîðóþ êîïèðóþòñÿ çíà÷åíèÿ ìåòðèê ïåðåä èõ ñåðèàëèçàöèåé
- struct ClientMetric {
- // Label
- struct Label {
- std::string name;
- std::string value;
- Label(const std::string name_, const std::string value_) : name(name_), value(value_) {}
- bool operator<(const Label& rhs) const {
- return std::tie(name, value) < std::tie(rhs.name, rhs.value);
- }
- bool operator==(const Label& rhs) const {
- return std::tie(name, value) == std::tie(rhs.name, rhs.value);
- }
- };
- std::vector<Label> label;
- // Counter
- struct Counter {
- double value = 0.0;
- };
- Counter counter;
- // Gauge
- struct Gauge {
- double value = 0.0;
- };
- Gauge gauge;
- // Summary
- struct Quantile {
- double quantile = 0.0;
- double value = 0.0;
- };
- struct Summary {
- std::uint64_t sample_count = 0;
- double sample_sum = 0.0;
- std::vector<Quantile> quantile;
- };
- Summary summary;
- // Histogram
- struct Bucket {
- std::uint64_t cumulative_count = 0;
- double upper_bound = 0.0;
- };
- struct Histogram {
- std::uint64_t sample_count = 0;
- double sample_sum = 0.0;
- std::vector<Bucket> bucket;
- };
- Histogram histogram;
- // Untyped
- struct Untyped {
- double value = 0;
- };
- Untyped untyped;
- // Timestamp
- std::int64_t timestamp_ms = 0;
- };
- } // namespace prometheus
|