8 Metrics global_metrics;
10 void Metrics::register_int_metric(const string &name, atomic<int64_t> *location)
12 lock_guard<mutex> lock(mu);
13 int_metrics.emplace(name, location);
16 void Metrics::register_double_metric(const string &name, atomic<double> *location)
18 lock_guard<mutex> lock(mu);
19 double_metrics.emplace(name, location);
22 string Metrics::serialize() const
25 ss.imbue(locale("C"));
29 lock_guard<mutex> lock(mu);
30 for (const auto &key_and_value : int_metrics) {
31 ss << "nageru_" << key_and_value.first.c_str() << " " << key_and_value.second->load() << "\n";
33 for (const auto &key_and_value : double_metrics) {
34 ss << "nageru_" << key_and_value.first.c_str() << " " << key_and_value.second->load() << "\n";