metrics: any DNS error fails to report correctly
Thanks to https://lists.torproject.org/pipermail/tor-relays/2021-October/019917.html
I can confirm this report as well. Basically, libevent
doesn't report the type
(A, AAAA, PTR) when a DNS error occurs. In libevent, the function reply_run_callback()
calls back like so:
cb->user_callback(cb->err, 0, 0, cb->ttl, NULL, user_pointer);
... where type
is the second parameter which is always 0. I have no idea why it is done this way but that is what we need to work with.
Which means that rep_hist_note_dns_error(type, result)
always use 0 as the type and that doesn't exists when get_dns_stats_by_type(0)
is called leading to never recording DNS errors.
I think we should lobby libevent to fix that because I really don't see why it doesn't report the request type. But we'll have to fix that in our code to record all DNS errors without the type and so the reporting will be a blanket "DNS error" instead of being per-type on the metrics port.
This only affects the reporting on the MetricsPort
and not the overload state fortunately.