From: Otto Date: Tue, 29 Jun 2021 09:03:27 +0000 (+0200) Subject: Disable cumul stats by default except for API plus some other X-Git-Tag: dnsdist-1.7.0-alpha1~116^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a74ad8577f81c6ecab27acbd00f801ac06f1730d;p=thirdparty%2Fpdns.git Disable cumul stats by default except for API plus some other assorted review comments. --- diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index af1294f806..f1204784dd 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -2818,10 +2818,9 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) bool cacheHit = checkForCacheHit(qnameParsed, dc->d_tag, conn->data, qname, qtype, qclass, g_now, response, dc->d_qhash, pbData, true, dc->d_source); if (cacheHit) { - struct timeval now; - Utility::gettimeofday(&now, nullptr); if (t_protobufServers && dc->d_logResponse && !(luaconfsLocal->protobufExportConfig.taggedOnly && pbData && !pbData->d_tagged)) { - protobufLogResponse(dh, luaconfsLocal, pbData, now, true, dc->d_source, dc->d_destination, dc->d_ednssubnet, dc->d_uuid, dc->d_requestorId, dc->d_deviceId, dc->d_deviceName); + struct timeval tv{0, 0}; + protobufLogResponse(dh, luaconfsLocal, pbData, tv, true, dc->d_source, dc->d_destination, dc->d_ednssubnet, dc->d_uuid, dc->d_requestorId, dc->d_deviceId, dc->d_deviceName); } if (!g_quiet) { @@ -2830,6 +2829,7 @@ static void handleRunningTCPQuestion(int fd, FDMultiplexer::funcparam_t& var) bool hadError = sendResponseOverTCP(dc, response); finishTCPReply(dc, hadError, false); + struct timeval now; Utility::gettimeofday(&now, nullptr); uint64_t spentUsec = uSec(now - start); g_stats.cumulativeAnswers(spentUsec); @@ -5798,26 +5798,28 @@ int main(int argc, char **argv) ::arg().set("include-dir","Include *.conf files from this directory")=""; ::arg().set("security-poll-suffix","Domain name from which to query security update notifications")="secpoll.powerdns.com."; - + ::arg().setSwitch("reuseport","Enable SO_REUSEPORT allowing multiple recursors processes to listen to 1 address")="no"; ::arg().setSwitch("snmp-agent", "If set, register as an SNMP agent")="no"; ::arg().set("snmp-master-socket", "If set and snmp-agent is set, the socket to use to register to the SNMP daemon (deprecated)")=""; ::arg().set("snmp-daemon-socket", "If set and snmp-agent is set, the socket to use to register to the SNMP daemon")=""; - std::string defaultDisabledStats = "cache-bytes, packetcache-bytes, special-memory-usage"; + std::string defaultAPIDisabledStats = "cache-bytes, packetcache-bytes, special-memory-usage"; for (size_t idx = 0; idx < 32; idx++) { - defaultDisabledStats += ", ecs-v4-response-bits-" + std::to_string(idx + 1); + defaultAPIDisabledStats += ", ecs-v4-response-bits-" + std::to_string(idx + 1); } for (size_t idx = 0; idx < 128; idx++) { - defaultDisabledStats += ", ecs-v6-response-bits-" + std::to_string(idx + 1); + defaultAPIDisabledStats += ", ecs-v6-response-bits-" + std::to_string(idx + 1); } - ::arg().set("stats-api-blacklist", "List of statistics that are disabled when retrieving the complete list of statistics via the API (deprecated)")=defaultDisabledStats; + std::string defaultDisabledStats = defaultAPIDisabledStats + ", cumul-answers, cumul-auth4answers, cumul-auth6answers"; + + ::arg().set("stats-api-blacklist", "List of statistics that are disabled when retrieving the complete list of statistics via the API (deprecated)")=defaultAPIDisabledStats; ::arg().set("stats-carbon-blacklist", "List of statistics that are prevented from being exported via Carbon (deprecated)")=defaultDisabledStats; ::arg().set("stats-rec-control-blacklist", "List of statistics that are prevented from being exported via rec_control get-all (deprecated)")=defaultDisabledStats; ::arg().set("stats-snmp-blacklist", "List of statistics that are prevented from being exported via SNMP (deprecated)")=defaultDisabledStats; - ::arg().set("stats-api-disabled-list", "List of statistics that are disabled when retrieving the complete list of statistics via the API")=defaultDisabledStats; + ::arg().set("stats-api-disabled-list", "List of statistics that are disabled when retrieving the complete list of statistics via the API")=defaultAPIDisabledStats; ::arg().set("stats-carbon-disabled-list", "List of statistics that are prevented from being exported via Carbon")=defaultDisabledStats; ::arg().set("stats-rec-control-disabled-list", "List of statistics that are prevented from being exported via rec_control get-all")=defaultDisabledStats; ::arg().set("stats-snmp-disabled-list", "List of statistics that are prevented from being exported via SNMP")=defaultDisabledStats; diff --git a/pdns/rec_channel.hh b/pdns/rec_channel.hh index 7b197665e8..737df84381 100644 --- a/pdns/rec_channel.hh +++ b/pdns/rec_channel.hh @@ -95,7 +95,7 @@ struct StatsMapEntry { std::string d_value; }; -class SimpleNaturalCompare +class PrefixDashNumberCompare { private: static std::pair prefixAndTrailingNum(const std::string& a); @@ -103,7 +103,7 @@ public: bool operator()(const std::string& a, const std::string& b) const; }; -typedef std::map StatsMap; +typedef std::map StatsMap; StatsMap getAllStatsMap(StatComponent component); diff --git a/pdns/rec_channel_rec.cc b/pdns/rec_channel_rec.cc index 0c6b223eaf..e1eb007f58 100644 --- a/pdns/rec_channel_rec.cc +++ b/pdns/rec_channel_rec.cc @@ -40,7 +40,7 @@ #include "namespaces.hh" #include "rec-taskqueue.hh" -std::pair SimpleNaturalCompare::prefixAndTrailingNum(const std::string& a) +std::pair PrefixDashNumberCompare::prefixAndTrailingNum(const std::string& a) { auto i = a.length(); if (i == 0) { @@ -59,7 +59,7 @@ std::pair SimpleNaturalCompare::prefixAndTrailingNum(c return make_pair(a.substr(0, i + 1), a.substr(i + 1, a.size() - i - 1)); } -bool SimpleNaturalCompare::operator()(const std::string& a, const std::string& b) const +bool PrefixDashNumberCompare::operator()(const std::string& a, const std::string& b) const { auto [aprefix, anum] = prefixAndTrailingNum(a); auto [bprefix, bnum] = prefixAndTrailingNum(b); diff --git a/pdns/recursordist/docs/settings.rst b/pdns/recursordist/docs/settings.rst index d9465ab4d7..75d73b83e8 100644 --- a/pdns/recursordist/docs/settings.rst +++ b/pdns/recursordist/docs/settings.rst @@ -1809,7 +1809,7 @@ These statistics can still be retrieved individually by specifically asking for .. versionadded:: 4.5.0 - String -- Default: "cache-bytes, packetcache-bytes, special-memory-usage, ecs-v4-response-bits-*, ecs-v6-response-bits-*" +- Default: "cache-bytes, packetcache-bytes, special-memory-usage, ecs-v4-response-bits-*, ecs-v6-response-bits-*, cumul-answers-*, cumul-auth4answers-*, cumul-auth6answers-*" A list of comma-separated statistic names, that are prevented from being exported via carbon for performance reasons. @@ -1828,7 +1828,7 @@ A list of comma-separated statistic names, that are prevented from being exporte .. versionadded:: 4.5.0 - String -- Default: "cache-bytes, packetcache-bytes, special-memory-usage, ecs-v4-response-bits-*, ecs-v6-response-bits-*" +- Default: "cache-bytes, packetcache-bytes, special-memory-usage, ecs-v4-response-bits-*, ecs-v6-response-bits-*, cumul-answers-*, cumul-auth4answers-*, cumul-auth6answers-*" A list of comma-separated statistic names, that are disabled when retrieving the complete list of statistics via `rec_control get-all`, for performance reasons. These statistics can still be retrieved individually. diff --git a/pdns/ws-recursor.cc b/pdns/ws-recursor.cc index 71566be971..56f9722dc5 100644 --- a/pdns/ws-recursor.cc +++ b/pdns/ws-recursor.cc @@ -1048,7 +1048,7 @@ const std::map MetricDefinitionStorage::metrics = "histogram of authoritative answer times over IPV6")}, }; -#define CHECK_PROMETHEUS_METRICS 1 +#define CHECK_PROMETHEUS_METRICS 0 #if CHECK_PROMETHEUS_METRICS static void validatePrometheusMetrics()