• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 21361274430

26 Jan 2026 02:28PM UTC coverage: 71.533% (+4.1%) from 67.39%
21361274430

push

github

web-flow
Merge pull request #16768 from rgacogne/and-in-the-darkness-bind-them

dnsdist: Implement sampling in our in-memory ring buffers

44772 of 77566 branches covered (57.72%)

Branch coverage included in aggregate %.

245 of 265 new or added lines in 12 files covered. (92.45%)

43 existing lines in 9 files now uncovered.

129243 of 165698 relevant lines covered (78.0%)

7830511.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

73.08
/pdns/statnode.hh
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22
#pragma once
23
#include "dnsname.hh"
24
#include <map>
25
#include "iputils.hh"
26

27
class StatNode
28
{
29
public:
30

31
  struct Stat
32
  {
33
    Stat() {};
1,497✔
34
    uint64_t queries{0};
35
    uint64_t noerrors{0};
36
    uint64_t nxdomains{0};
37
    uint64_t servfails{0};
38
    uint64_t drops{0};
39
    uint64_t bytes{0};
40
    uint64_t hits{0};
41
    using remotes_t = std::map<ComboAddress,int,ComboAddress::addressOnlyLessThan>;
42
    remotes_t remotes;
43

44
    Stat& operator+=(const Stat& rhs) {
1,072✔
45
      queries += rhs.queries;
1,072✔
46
      noerrors += rhs.noerrors;
1,072✔
47
      nxdomains += rhs.nxdomains;
1,072✔
48
      servfails += rhs.servfails;
1,072✔
49
      drops += rhs.drops;
1,072✔
50
      bytes += rhs.bytes;
1,072✔
51
      hits += rhs.hits;
1,072✔
52

53
      for (const remotes_t::value_type& rem : rhs.remotes) {
1,072!
54
        remotes[rem.first] += rem.second;
×
55
      }
×
56
      return *this;
1,072✔
57
    }
1,072✔
58
  };
59

60
  using visitor_t = std::function<void(const StatNode*, const Stat& selfstat, const Stat& childstat)>;
61

62
  Stat s;
63
  std::string name;
64
  std::string fullname;
65
  uint8_t labelsCount{0};
66

67
  void submit(const DNSName& domain, int rcode, uint32_t bytes, bool hit, const std::optional<ComboAddress>& remote, size_t samplingRate);
68
  Stat print(unsigned int depth=0, Stat newstat=Stat(), bool silent=false) const;
69
  void visit(const visitor_t& visitor, Stat& newstat, unsigned int depth = 0) const;
70
  bool empty() const
71
  {
413✔
72
    return children.empty() && s.remotes.empty();
413!
73
  }
413✔
74
  size_t size() const
NEW
75
  {
×
NEW
76
    return children.size();
×
NEW
77
  }
×
78

79
private:
80
  void submit(std::vector<string>::const_iterator end, std::vector<string>::const_iterator begin, const std::string& domain, int rcode, uint32_t bytes, const std::optional<ComboAddress>& remote, unsigned int count, bool hit, size_t samplingRate);
81

82
  using children_t = std::map<std::string, StatNode, CIStringCompare>;
83
  children_t children;
84
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc