@@ -33,9 +33,12 @@ void DaemonMetricCollector::request_loop(boost::asio::steady_timer &timer) {
3333 timer.async_wait ([&](const boost::system::error_code &e) {
3434 std::cerr << e << std::endl;
3535 update_sockets ();
36+
37+ bool sort_metrics = g_conf ().get_val <bool >(" exporter_sort_metrics" );
38+ auto prio_limit = g_conf ().get_val <int64_t >(" exporter_prio_limit" );
3639 std::string dump_response;
3740 std::string schema_response;
38- dump_asok_metrics (false , - 1 , true , dump_response, schema_response, true );
41+ dump_asok_metrics (sort_metrics, prio_limit , true , dump_response, schema_response, true );
3942 auto stats_period = g_conf ().get_val <int64_t >(" exporter_stats_period" );
4043 // time to wait before sending requests again
4144 timer.expires_from_now (std::chrono::seconds (stats_period));
@@ -153,16 +156,14 @@ void DaemonMetricCollector::dump_asok_metrics(bool sort_metrics, int64_t counter
153156 std::vector<std::pair<std::string, int >> daemon_pids;
154157
155158 int failures = 0 ;
156- bool sort;
157- sort = sort_metrics ? true : g_conf ().get_val <bool >(" exporter_sort_metrics" );
158- if (sort) {
159+ if (sort_metrics) {
159160 builder =
160161 std::unique_ptr<OrderedMetricsBuilder>(new OrderedMetricsBuilder ());
161162 } else {
162163 builder =
163164 std::unique_ptr<UnorderedMetricsBuilder>(new UnorderedMetricsBuilder ());
164165 }
165- auto prio_limit = counter_prio >= 0 ? counter_prio : g_conf (). get_val < int64_t >( " exporter_prio_limit " ) ;
166+ auto prio_limit = counter_prio;
166167 for (auto &[daemon_name, sock_client] : clients) {
167168 if (sockClientsPing) {
168169 bool ok;
@@ -186,6 +187,9 @@ void DaemonMetricCollector::dump_asok_metrics(bool sort_metrics, int64_t counter
186187 }
187188
188189 try {
190+ parse_asok_metrics (counter_dump_response, counter_schema_response,
191+ prio_limit, daemon_name);
192+
189193 std::string config_show = !config_show_response ? " " :
190194 asok_request (sock_client, " config show" , daemon_name);
191195 if (config_show.size () == 0 ) {
@@ -203,8 +207,6 @@ void DaemonMetricCollector::dump_asok_metrics(bool sort_metrics, int64_t counter
203207 if (!pid_str.empty ()) {
204208 daemon_pids.push_back ({daemon_name, std::stoi (pid_str)});
205209 }
206- parse_asok_metrics (counter_dump_response, counter_schema_response,
207- prio_limit, daemon_name);
208210 } catch (const std::invalid_argument &e) {
209211 failures++;
210212 dout (1 ) << " failed to handle " << daemon_name << " : " << e.what ()
0 commit comments