From: Mischan Toosarani-Hausberger Date: Tue, 2 Jun 2020 18:40:03 +0000 (+0200) Subject: auth: Change StatType for some metrics from counter to gauge X-Git-Tag: dnsdist-1.5.0-rc3~22^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=33b222ed758ada65a9865cd6398a6a48fb905c00;p=thirdparty%2Fpdns.git auth: Change StatType for some metrics from counter to gauge "packetcache-size" and "query-cache-size" are both decremented and incremented and thus clearly gauges. "security-status" is an ordered category and thus also qualifies as a gauge. --- diff --git a/docs/http-api/index.rst b/docs/http-api/index.rst index decfd4dc26..81ee64ea17 100644 --- a/docs/http-api/index.rst +++ b/docs/http-api/index.rst @@ -79,7 +79,7 @@ A simple ``GET`` request will return a response similar to the following: # TYPE pdns_auth_packetcache_miss counter pdns_auth_packetcache_miss 0 # HELP pdns_auth_packetcache_size Number of entries in the packet cache - # TYPE pdns_auth_packetcache_size counter + # TYPE pdns_auth_packetcache_size gauge pdns_auth_packetcache_size 0 # HELP pdns_auth_query_cache_hit Number of hits on the query cache # TYPE pdns_auth_query_cache_hit counter @@ -88,7 +88,7 @@ A simple ``GET`` request will return a response similar to the following: # TYPE pdns_auth_query_cache_miss counter pdns_auth_query_cache_miss 0 # HELP pdns_auth_query_cache_size Number of entries in the query cache - # TYPE pdns_auth_query_cache_size counter + # TYPE pdns_auth_query_cache_size gauge pdns_auth_query_cache_size 0 # HELP pdns_auth_rd_queries Number of recursion desired questions # TYPE pdns_auth_rd_queries counter @@ -103,7 +103,7 @@ A simple ``GET`` request will return a response similar to the following: # TYPE pdns_auth_recursion_unanswered counter pdns_auth_recursion_unanswered 0 # HELP pdns_auth_security_status Security status based on regular polling - # TYPE pdns_auth_security_status counter + # TYPE pdns_auth_security_status gauge pdns_auth_security_status 0 # HELP pdns_auth_servfail_packets Number of times a server-failed packet was sent out # TYPE pdns_auth_servfail_packets counter diff --git a/pdns/auth-packetcache.cc b/pdns/auth-packetcache.cc index 759864e588..1cb554f44e 100644 --- a/pdns/auth-packetcache.cc +++ b/pdns/auth-packetcache.cc @@ -34,7 +34,7 @@ AuthPacketCache::AuthPacketCache(size_t mapsCount): d_maps(mapsCount), d_lastcle { S.declare("packetcache-hit", "Number of hits on the packet cache"); S.declare("packetcache-miss", "Number of misses on the packet cache"); - S.declare("packetcache-size", "Number of entries in the packet cache"); + S.declare("packetcache-size", "Number of entries in the packet cache", StatType::gauge); S.declare("deferred-packetcache-inserts","Amount of packet cache inserts that were deferred because of maintenance"); S.declare("deferred-packetcache-lookup","Amount of packet cache lookups that were deferred because of maintenance"); diff --git a/pdns/auth-querycache.cc b/pdns/auth-querycache.cc index f98d9b133d..82489e1e92 100644 --- a/pdns/auth-querycache.cc +++ b/pdns/auth-querycache.cc @@ -35,7 +35,7 @@ AuthQueryCache::AuthQueryCache(size_t mapsCount): d_maps(mapsCount), d_lastclean { S.declare("query-cache-hit","Number of hits on the query cache"); S.declare("query-cache-miss","Number of misses on the query cache"); - S.declare("query-cache-size", "Number of entries in the query cache"); + S.declare("query-cache-size", "Number of entries in the query cache", StatType::gauge); S.declare("deferred-cache-inserts","Amount of cache inserts that were deferred because of maintenance"); S.declare("deferred-cache-lookup","Amount of cache lookups that were deferred because of maintenance"); diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 1c67740d22..fe4994cc13 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -370,7 +370,7 @@ void declareStats(void) S.declare("servfail-packets","Number of times a server-failed packet was sent out"); S.declare("latency","Average number of microseconds needed to answer a question", getLatency, StatType::gauge); S.declare("timedout-packets","Number of packets which weren't answered within timeout set"); - S.declare("security-status", "Security status based on regular polling"); + S.declare("security-status", "Security status based on regular polling", StatType::gauge); S.declareDNSNameQTypeRing("queries","UDP Queries Received"); S.declareDNSNameQTypeRing("nxdomain-queries","Queries for non-existent records within existent domains"); S.declareDNSNameQTypeRing("noerror-queries","Queries for existing records, but for type we don't have"); diff --git a/pdns/statbag.cc b/pdns/statbag.cc index 3dd5a8de12..70eddcb244 100644 --- a/pdns/statbag.cc +++ b/pdns/statbag.cc @@ -103,12 +103,12 @@ StatType StatBag::getStatType(const string &item) return d_statTypes[item]; } -void StatBag::declare(const string &key, const string &descrip) +void StatBag::declare(const string &key, const string &descrip, StatType statType) { auto i=make_unique(0); d_stats[key]=std::move(i); d_keyDescrips[key]=descrip; - d_statTypes[key]=StatType::counter; + d_statTypes[key]=statType; } void StatBag::declare(const string &key, const string &descrip, StatBag::func_t func, StatType statType) diff --git a/pdns/statbag.hh b/pdns/statbag.hh index 3026912590..1887b7833a 100644 --- a/pdns/statbag.hh +++ b/pdns/statbag.hh @@ -87,7 +87,7 @@ class StatBag public: StatBag(); //!< Naked constructor. You need to declare keys before this class becomes useful ~StatBag(); - void declare(const string &key, const string &descrip=""); //!< Before you can store or access a key, you need to declare it + void declare(const string &key, const string &descrip="", StatType statType=StatType::counter); //!< Before you can store or access a key, you need to declare it void declare(const string &key, const string &descrip, func_t func, StatType statType); //!< Before you can store or access a key, you need to declare it void declareRing(const string &name, const string &title, unsigned int size=10000);