4 // A simple global class to keep track of metrics export in Prometheus format.
5 // It would be better to use a more full-featured Prometheus client library for this,
6 // but it would introduce a dependency that is not commonly packaged in distributions,
7 // which makes it quite unwieldy. Thus, we'll package our own for the time being.
22 void add(const std::string &name, std::atomic<int64_t> *location, Type type = TYPE_COUNTER)
24 add(name, {}, location, type);
27 void add(const std::string &name, std::atomic<double> *location, Type type = TYPE_COUNTER)
29 add(name, {}, location, type);
32 void add(const std::string &name, const std::vector<std::pair<std::string, std::string>> &labels, std::atomic<int64_t> *location, Type type = TYPE_COUNTER);
33 void add(const std::string &name, const std::vector<std::pair<std::string, std::string>> &labels, std::atomic<double> *location, Type type = TYPE_COUNTER);
35 std::string serialize() const;
46 std::vector<std::pair<std::string, std::string>> labels;
48 std::atomic<int64_t> *location_int64;
49 std::atomic<double> *location_double;
53 mutable std::mutex mu;
54 std::map<std::string, Type> types;
55 std::vector<Metric> metrics;
58 extern Metrics global_metrics;
60 #endif // !defined(_METRICS_H)