From 19178da979e43b3d9c6614695cc4988b503354ad Mon Sep 17 00:00:00 2001 From: bert hubert Date: Fri, 6 Oct 2017 13:20:15 +0200 Subject: [PATCH] Implement experimental metric tracking time spent within PowerDNS per query With this commit, PowerDNS provides metrics on the difference between the time spent waiting for authoritative servers, and the amount of time elapsed between arrival of query and sending out the response. This metric should be seen as experimental until operational experience proves its relevance. --- pdns/pdns_recursor.cc | 25 +++++++++++++++++- pdns/rec_channel_rec.cc | 10 +++++++ pdns/recursordist/docs/metrics.rst | 42 ++++++++++++++++++++++++++++++ pdns/syncres.hh | 4 ++- 4 files changed, 79 insertions(+), 2 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 01fc6e3415..55b88eeb0e 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -1237,7 +1237,7 @@ static void startDoResolve(void *p) } sr.d_outqueries ? t_RC->cacheMisses++ : t_RC->cacheHits++; - + if(spent < 0.001) g_stats.answers0_1++; else if(spent < 0.010) @@ -1253,6 +1253,28 @@ static void startDoResolve(void *p) newLat = min(newLat,(uint64_t)(((uint64_t) g_networkTimeoutMsec)*1000)); // outliers of several minutes exist.. g_stats.avgLatencyUsec=(1-1.0/g_latencyStatSize)*g_stats.avgLatencyUsec + (float)newLat/g_latencyStatSize; // no worries, we do this for packet cache hits elsewhere + + auto ourtime = 1000.0*spent-sr.d_totUsec/1000.0; // in msec + if(ourtime < 1) + g_stats.ourtime0_1++; + else if(ourtime < 2) + g_stats.ourtime1_2++; + else if(ourtime < 4) + g_stats.ourtime2_4++; + else if(ourtime < 8) + g_stats.ourtime4_8++; + else if(ourtime < 16) + g_stats.ourtime8_16++; + else if(ourtime < 32) + g_stats.ourtime16_32++; + else { + // cerr<<"SLOW: "< "<d_mdp.d_qname<<"|"<d_mdp.d_qtype)<d_mdp.d_qname<<"\t"<getUsec()<<"\t"< answers0_1, answers1_10, answers10_100, answers100_1000, answersSlow; std::atomic auth4Answers0_1, auth4Answers1_10, auth4Answers10_100, auth4Answers100_1000, auth4AnswersSlow; std::atomic auth6Answers0_1, auth6Answers1_10, auth6Answers10_100, auth6Answers100_1000, auth6AnswersSlow; - double avgLatencyUsec; + std::atomic ourtime0_1, ourtime1_2, ourtime2_4, ourtime4_8, ourtime8_16, ourtime16_32, ourtimeSlow; + double avgLatencyUsec{0}; + double avgLatencyOursUsec{0}; std::atomic qcounter; // not increased for unauth packets std::atomic ipv6qcounter; std::atomic tcpqcounter; -- 2.47.3