Modularize resolver statistics
The extendibility of the legacy resolver statistics is limited because
it was originally designed for libc, which is hard to implement to
support other types of DNS, e.g. DNS-over-TLS. Therefore, DnsStats
is introduced to manage the statistics in a more general way.
DoT statistics is now available from DnsStats and is shown in
dumpsys dnsresolver.
Example of output from dumpsys dnsresolver:
Server statistics: (total, RTT avg, {rcode:counts}, last update)
over UDP
8.8.4.4 <no data>
8.8.8.8 <no data>
2001:4860:4860::8844 (7, 2201ms, [NOERROR:4 TIMEOUT:3 ], 2s)
2001:4860:4860::8888 (3, 11ms, [NOERROR:3 ], 4s)
over TLS
<no server>
over TCP
8.8.4.4 <no data>
8.8.8.8 <no data>
2001:4860:4860::8844 <no data>
2001:4860:4860::8888 <no data>
Bug: 140286585
Test: atest --include-subdirs packages/modules/DnsResolver
Test: checked output in dumpsys dnsresolver
Change-Id: I73f0108d5e9bb493cf7eda68252f5a0922149a98
diff --git a/res_send.cpp b/res_send.cpp
index 9eee05d..1dc5f57 100644
--- a/res_send.cpp
+++ b/res_send.cpp
@@ -130,6 +130,7 @@
using android::net::PrivateDnsStatus;
using android::net::PROTO_TCP;
using android::net::PROTO_UDP;
+using android::netdutils::IPSockAddr;
using android::netdutils::Slice;
using android::netdutils::Stopwatch;
@@ -544,6 +545,7 @@
_res_stats_set_sample(&sample, now, *rcode, delay);
_resolv_cache_add_resolver_stats_sample(statp->netid, revision_id, ns, &sample,
params.max_samples);
+ resolv_stats_add(statp->netid, IPSockAddr::toIPSockAddr(*nsap), dnsQueryEvent);
}
LOG(INFO) << __func__ << ": used send_vc " << n;
@@ -577,6 +579,7 @@
_res_stats_set_sample(&sample, now, *rcode, delay);
_resolv_cache_add_resolver_stats_sample(statp->netid, revision_id, ns, &sample,
params.max_samples);
+ resolv_stats_add(statp->netid, IPSockAddr::toIPSockAddr(*nsap), dnsQueryEvent);
}
LOG(INFO) << __func__ << ": used send_dg " << n;