Skip to content

Commit

Permalink
switch notimpStats to array, thanks @rgacogne
Browse files Browse the repository at this point in the history
  • Loading branch information
Habbie committed Oct 19, 2023
1 parent 0669936 commit c8166ef
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 7 deletions.
8 changes: 6 additions & 2 deletions pdns/ixfrdist-stats.cc
Expand Up @@ -90,8 +90,12 @@ std::string ixfrdistStats::getStats() {
stats<<"# TYPE "<<prefix<<"notimp counter"<<std::endl;
}

for (auto const &d : notimpStats) {
stats<<prefix<<"notimp{opcode=\""<<d.first<<"\"} "<<d.second<<std::endl;
for (std::size_t i = 0; i < notimpStats.size() ; i++) {
auto val = notimpStats.at(i).load();

if (val > 0) {
stats<<prefix<<"notimp{opcode=\""<<Opcode::to_s(i)<<"\"} "<<val<<std::endl;
}
}

stats<<"# HELP "<<prefix<<"unknown_domain_inqueries_total Number of queries received for domains unknown to us"<<std::endl;
Expand Down
6 changes: 3 additions & 3 deletions pdns/ixfrdist-stats.hh
Expand Up @@ -71,9 +71,9 @@ class ixfrdistStats {
progStats.unknownDomainInQueries += 1;
}

void incrementNotImplemented(const string& opcode)
void incrementNotImplemented(uint8_t opcode)
{
notimpStats[opcode] ++;
notimpStats.at(opcode) ++;
}

private:
Expand All @@ -99,7 +99,7 @@ class ixfrdistStats {
};

std::map<DNSName, perDomainStat> domainStats;
std::map<string, std::atomic<uint64_t>> notimpStats;
std::array<std::atomic<uint64_t>, 16> notimpStats;
programStats progStats;

std::map<DNSName, perDomainStat>::iterator getRegisteredDomain(const DNSName& d) {
Expand Down
2 changes: 1 addition & 1 deletion pdns/ixfrdist.cc
Expand Up @@ -959,7 +959,7 @@ try
g_stats.incrementUnknownDomainInQueries(mdp.d_qname);
makeRefusedPacket(mdp, packet);
} else if (respt == ResponseType::RefusedOpcode) {
g_stats.incrementNotImplemented(Opcode::to_s(mdp.d_header.opcode));
g_stats.incrementNotImplemented(mdp.d_header.opcode);
makeNotimpPacket(mdp, packet);
}

Expand Down
3 changes: 2 additions & 1 deletion regression-tests.ixfrdist/test_Stats.py
Expand Up @@ -33,7 +33,8 @@ class IXFRDistStatsTest(IXFRDistTest):
"ixfrdist_unknown_domain_inqueries_total",
"ixfrdist_sys_msec", "ixfrdist_user_msec",
"ixfrdist_real_memory_usage",
"ixfrdist_fd_usage"]
"ixfrdist_fd_usage",
"ixfrdist_notimp"]
metric_domain_stats = ["ixfrdist_soa_serial", "ixfrdist_soa_checks_total",
"ixfrdist_soa_checks_failed_total",
"ixfrdist_soa_inqueries_total",
Expand Down

0 comments on commit c8166ef

Please sign in to comment.