From 3bc32eb4d549862fc3af600c913c15677b4aaa48 Mon Sep 17 00:00:00 2001 From: Jose Nino Date: Mon, 4 Oct 2021 11:58:17 -0700 Subject: [PATCH] dns resolvers: add more details to debug logging Signed-off-by: Jose Nino --- source/common/network/apple_dns_impl.cc | 10 +++++++++- source/common/network/dns_impl.cc | 11 ++++++++--- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/source/common/network/apple_dns_impl.cc b/source/common/network/apple_dns_impl.cc index 9a423621acbf3..a3b5a5b2a743b 100644 --- a/source/common/network/apple_dns_impl.cc +++ b/source/common/network/apple_dns_impl.cc @@ -13,6 +13,7 @@ #include "source/common/common/assert.h" #include "source/common/common/fmt.h" +#include "source/common/common/stl_helpers.h" #include "source/common/network/address_impl.h" #include "source/common/network/utility.h" @@ -210,7 +211,14 @@ std::list& AppleDnsResolverImpl::PendingResolution::finalAddressLis void AppleDnsResolverImpl::PendingResolution::finishResolve() { ENVOY_LOG_EVENT(debug, "apple_dns_resolution_complete", - "dns resolution for {} completed with status {}", dns_name_, pending_cb_.status_); + "dns resolution for {} completed with status={} v4_addresses={} v6_addresses={}", + dns_name_, pending_cb_.status_, + accumulateToString( + pending_cb_.v4_responses_, + [](const auto& dns_response) { return dns_response.address_->asString(); }), + accumulateToString( + pending_cb_.v4_responses_, + [](const auto& dns_response) { return dns_response.address_->asString(); })); callback_(pending_cb_.status_, std::move(finalAddressList())); if (owned_) { diff --git a/source/common/network/dns_impl.cc b/source/common/network/dns_impl.cc index 7e1bf8f1f7e03..cfb637146d51d 100644 --- a/source/common/network/dns_impl.cc +++ b/source/common/network/dns_impl.cc @@ -10,6 +10,7 @@ #include "source/common/common/assert.h" #include "source/common/common/fmt.h" +#include "source/common/common/stl_helpers.h" #include "source/common/common/thread.h" #include "source/common/network/address_impl.h" #include "source/common/network/utility.h" @@ -183,9 +184,13 @@ void DnsResolverImpl::PendingResolution::onAresGetAddrInfoCallback(int status, i // portFromTcpUrl(). // TODO(chaoqin-li1123): remove try catch pattern here once we figure how to handle unexpected // exception in fuzz tests. - ENVOY_LOG_EVENT(debug, "cares_dns_resolution_complete", - "dns resolution for {} completed with status {}", dns_name_, - resolution_status); + ENVOY_LOG_EVENT( + debug, "cares_dns_resolution_complete", + "dns resolution for {} completed with status={} addresses={}", dns_name_, + resolution_status, + accumulateToString(address_list, [](const auto& dns_response) { + return dns_response.address_->asString(); + })); TRY_NEEDS_AUDIT { callback_(resolution_status, std::move(address_list)); } catch (const EnvoyException& e) {