Skip to content

Commit

Permalink
Add a metric to track unresolved DNS hosts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sudheer Vinukonda committed Aug 6, 2018
1 parent 5cb0453 commit da4a19f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

package com.netflix.zuul.netty.connectionpool;

import com.netflix.spectator.api.Counter;
import com.netflix.zuul.netty.SpectatorUtils;
import com.netflix.zuul.netty.server.Server;
import com.netflix.zuul.passport.CurrentPassport;
import io.netty.bootstrap.Bootstrap;
Expand All @@ -40,6 +42,7 @@ public class NettyClientConnectionFactory {

private final ConnectionPoolConfig connPoolConfig;
private final ChannelInitializer<? extends Channel> channelInitializer;
private final Counter unresolvedDiscoveryHost;

private static final Logger LOGGER = LoggerFactory.getLogger(NettyClientConnectionFactory.class);

Expand All @@ -48,6 +51,8 @@ public class NettyClientConnectionFactory {
final ChannelInitializer<? extends Channel> channelInitializer) {
this.connPoolConfig = connPoolConfig;
this.channelInitializer = channelInitializer;
this.unresolvedDiscoveryHost = SpectatorUtils.newCounter("unresolvedDiscoveryHost",
connPoolConfig.getOriginName() == null ? "unknownOrigin" : connPoolConfig.getOriginName());
}

public ChannelFuture connect(final EventLoop eventLoop, String host, final int port, CurrentPassport passport) {
Expand Down Expand Up @@ -79,6 +84,7 @@ public ChannelFuture connect(final EventLoop eventLoop, String host, final int p
ZuulBootstrap zuulBootstrap = new ZuulBootstrap(bootstrap);
if (!zuulBootstrap.getResolver(eventLoop).isResolved(socketAddress)) {
LOGGER.warn("NettyClientConnectionFactory got an unresolved server address, host: " + host + ", port: " + port);
unresolvedDiscoveryHost.increment();
}
return bootstrap.connect();
}
Expand Down

0 comments on commit da4a19f

Please sign in to comment.