void ProxyLogger::log() { std::vector<stat_t> stats(num_stats); try { proxy_->router->startupLock.wait(); std::lock_guard<ShutdownLock> lg(proxy_->router->shutdownLock()); std::lock_guard<std::mutex> guard(proxy_->stats_lock); prepare_stats(proxy_, stats.data()); } catch (const shutdown_started_exception& e) { return; } for (int i = 0; i < num_stats; ++i) { if (stats[i].group & rate_stats) { stats[i].type = stat_double; stats[i].data.dbl = stats_rate_value(proxy_, i); } } write_stats_to_disk(proxy_, stats); write_config_sources_info_to_disk(proxy_); for (const auto& filepath : touchStatsFilepaths_) { touchFile(filepath); } if (additionalLogger_) { additionalLogger_->log(stats); } }
void McrouterLogger::log() { std::vector<stat_t> stats(num_stats); prepare_stats(router_, stats.data()); for (int i = 0; i < num_stats; ++i) { if (stats[i].group & rate_stats) { stats[i].type = stat_double; stats[i].data.dbl = stats_aggregate_rate_value(router_, i); } else if (stats[i].group & max_stats) { stats[i].type = stat_uint64; stats[i].data.uint64 = stats_aggregate_max_value(router_, i); } } write_stats_to_disk(router_.opts(), stats); write_config_sources_info_to_disk(router_); for (const auto& filepath : touchStatsFilepaths_) { touchFile(filepath); } if (additionalLogger_) { additionalLogger_->log(stats); } }