time_t now=time(0);
for(const auto& e : g_stats.entries) {
str<<namespace_name<<"."<<hostname<<"."<<instance_name<<"."<<e.first<<' ';
- if(const auto& val = boost::get<pdns::stat_t*>(&e.second))
+ if (const auto& val = boost::get<pdns::stat_t*>(&e.second)) {
str<<(*val)->load();
- else if(const auto& adval = boost::get<pdns::stat_t_trait<double>*>(&e.second))
+ }
+ else if(const auto& adval = boost::get<pdns::stat_t_trait<double>*>(&e.second)) {
str<<(*adval)->load();
- else if (const auto& dval = boost::get<double*>(&e.second))
+ }
+ else if (const auto& dval = boost::get<double*>(&e.second)) {
str<<**dval;
- else
- str<<(*boost::get<DNSDistStats::statfunction_t>(&e.second))(e.first);
+ }
+ else if (const auto& func = boost::get<DNSDistStats::statfunction_t>(&e.second)) {
+ str<<(*func)(e.first);
+ }
str<<' '<<now<<"\r\n";
}
auto states = g_dstates.getLocal();
if (const auto& val = boost::get<pdns::stat_t*>(&e.second)) {
second = std::to_string((*val)->load());
}
- else if(const auto& adval = boost::get<pdns::stat_t_trait<double>*>(&e.second)) {
+ else if (const auto& adval = boost::get<pdns::stat_t_trait<double>*>(&e.second)) {
second = (flt % (*adval)->load()).str();
}
else if (const auto& dval = boost::get<double*>(&e.second)) {
second = (flt % (**dval)).str();
}
- else {
- second = std::to_string((*boost::get<DNSDistStats::statfunction_t>(&e.second))(e.first));
+ else if (const auto& func = boost::get<DNSDistStats::statfunction_t>(&e.second)) {
+ second = std::to_string((*func)(e.first));
}
if (leftcolumn.size() < g_stats.entries.size()/2) {
output << "# TYPE " << prometheusMetricName << " " << prometheusTypeName << "\n";
output << prometheusMetricName << " ";
- if (const auto& val = boost::get<pdns::stat_t*>(&std::get<1>(e)))
+ if (const auto& val = boost::get<pdns::stat_t*>(&std::get<1>(e))) {
output << (*val)->load();
- else if (const auto& adval = boost::get<pdns::stat_t_trait<double>*>(&std::get<1>(e)))
+ }
+ else if (const auto& adval = boost::get<pdns::stat_t_trait<double>*>(&std::get<1>(e))) {
output << (*adval)->load();
- else if (const auto& dval = boost::get<double*>(&std::get<1>(e)))
+ }
+ else if (const auto& dval = boost::get<double*>(&std::get<1>(e))) {
output << **dval;
- else
- output << (*boost::get<DNSDistStats::statfunction_t>(&std::get<1>(e)))(std::get<0>(e));
+ }
+ else if (const auto& func = boost::get<DNSDistStats::statfunction_t>(&std::get<1>(e))) {
+ output << (*func)(std::get<0>(e));
+ }
output << "\n";
}
obj.insert({e.first, (*adval)->load()});
} else if (const auto& dval = boost::get<double*>(&e.second)) {
obj.insert({e.first, (**dval)});
- } else {
- obj.insert({e.first, (double)(*boost::get<DNSDistStats::statfunction_t>(&e.second))(e.first)});
+ } else if (const auto& func = boost::get<DNSDistStats::statfunction_t>(&e.second)) {
+ obj.insert({e.first, (double)(*func)(e.first)});
}
}
}
{ "value", (**dval) }
});
}
- else {
+ else if (const auto& func = boost::get<DNSDistStats::statfunction_t>(&item.second)) {
doc.push_back(Json::object {
{ "type", "StatisticItem" },
{ "name", item.first },
- { "value", (double)(*boost::get<DNSDistStats::statfunction_t>(&item.second))(item.first) }
+ { "value", (double)(*func)(item.first) }
});
}
}