Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InstrumentedDnsResolver debug logging includes the client name #1583

Merged
merged 2 commits into from
Feb 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions changelog/@unreleased/pr-1583.v2.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type: improvement
improvement:
description: InstrumentedDnsResolver debug logging includes the client name
links:
- https://github.com/palantir/dialogue/pull/1583
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ public Socket createSocket(final HttpContext context) throws IOException {
// No maximum time to live
TimeValue.NEG_ONE_MILLISECOND,
null,
new InstrumentedDnsResolver(SystemDefaultDnsResolver.INSTANCE),
new InstrumentedDnsResolver(SystemDefaultDnsResolver.INSTANCE, name),
new InstrumentedManagedHttpConnectionFactory(
ManagedHttpClientConnectionFactory.INSTANCE, conf.taggedMetricRegistry(), name));
connectionManager.setDefaultSocketConfig(SocketConfig.custom()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ final class InstrumentedDnsResolver implements DnsResolver {

private static final SafeLogger log = SafeLoggerFactory.get(InstrumentedDnsResolver.class);
private final DnsResolver delegate;
private final String clientName;

InstrumentedDnsResolver(DnsResolver delegate) {
InstrumentedDnsResolver(DnsResolver delegate, String clientName) {
this.delegate = delegate;
this.clientName = clientName;
}

@Override
Expand All @@ -46,8 +48,9 @@ public InetAddress[] resolve(String host) throws UnknownHostException {
if (debugLoggingEnabled) {
long durationNanos = System.nanoTime() - startNanos;
log.debug(
"DnsResolver.resolve({}) produced '{}' ({} results) after {} ns",
"DnsResolver.resolve({}) on client {} produced '{}' ({} results) after {} ns",
UnsafeArg.of("host", host),
SafeArg.of("client", clientName),
resolved == null ? SafeArg.of("resolved", "null") : UnsafeArg.of("resolved", resolved),
SafeArg.of("numResolved", resolved == null ? 0 : resolved.length),
SafeArg.of("durationNanos", durationNanos));
Expand All @@ -57,8 +60,9 @@ public InetAddress[] resolve(String host) throws UnknownHostException {
if (debugLoggingEnabled) {
long durationNanos = System.nanoTime() - startNanos;
log.debug(
"DnsResolver.resolve({}) failed after {} ns",
"DnsResolver.resolve({}) on client {} failed after {} ns",
UnsafeArg.of("host", host),
SafeArg.of("client", clientName),
SafeArg.of("durationNanos", durationNanos),
t);
}
Expand All @@ -77,8 +81,9 @@ public String resolveCanonicalHostname(String host) throws UnknownHostException
if (debugLoggingEnabled) {
long durationNanos = System.nanoTime() - startNanos;
log.debug(
"DnsResolver.resolveCanonicalHostname({}) produced '{}' after {} ns",
"DnsResolver.resolveCanonicalHostname({}) on client {} produced '{}' after {} ns",
UnsafeArg.of("host", host),
SafeArg.of("client", clientName),
UnsafeArg.of("resolved", resolved),
SafeArg.of("durationNanos", durationNanos));
}
Expand All @@ -87,8 +92,9 @@ public String resolveCanonicalHostname(String host) throws UnknownHostException
if (debugLoggingEnabled) {
long durationNanos = System.nanoTime() - startNanos;
log.debug(
"DnsResolver.resolveCanonicalHostname({}) failed after {} ns",
"DnsResolver.resolveCanonicalHostname({}) on client {} failed after {} ns",
UnsafeArg.of("host", host),
SafeArg.of("client", clientName),
SafeArg.of("durationNanos", durationNanos),
t);
}
Expand Down