From 423910e01bce71d58ad909fd92a45ac4eccb54e5 Mon Sep 17 00:00:00 2001 From: David Goulet Date: Thu, 6 May 2021 09:46:02 -0400 Subject: dns: Gather DNS request statistics We now keep track of all errors and total number of request seen. This is so we can expose those values to the MetricsPort to help Exit operators monitor the DNS requests and failures. Related to #40367. Signed-off-by: David Goulet --- src/feature/relay/dns.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/feature/relay/dns.c') diff --git a/src/feature/relay/dns.c b/src/feature/relay/dns.c index 54c1de8903..c6e0439338 100644 --- a/src/feature/relay/dns.c +++ b/src/feature/relay/dns.c @@ -1650,6 +1650,10 @@ evdns_callback(int result, char type, int count, int ttl, void *addresses, dns_found_answer(string_address, orig_query_type, result, &addr, hostname, ttl); + /* The result can be changed within this function thus why we note the result + * at the end. */ + rep_hist_note_dns_error(type, result); + tor_free(arg_); } @@ -1668,6 +1672,9 @@ launch_one_resolve(const char *address, uint8_t query_type, addr[0] = (char) query_type; memcpy(addr+1, address, addr_len + 1); + /* Note the query for our statistics. */ + rep_hist_note_dns_request(query_type); + switch (query_type) { case DNS_IPv4_A: req = evdns_base_resolve_ipv4(the_evdns_base, -- cgit v1.2.3-54-g00ecf