@Test public void channelTracing_nameResolvedEvent_zeorAndNonzeroBackends() throws Exception { timer.forwardNanos(1234); channelBuilder.maxTraceEvents(10); List<EquivalentAddressGroup> servers = new ArrayList<>(); servers.add(new EquivalentAddressGroup(socketAddress)); FakeNameResolverFactory nameResolverFactory = new FakeNameResolverFactory.Builder(expectedUri).setServers(servers).build(); channelBuilder.nameResolverFactory(nameResolverFactory); createChannel(); int prevSize = getStats(channel).channelTrace.events.size(); nameResolverFactory.resolvers.get(0).listener.onAddresses( Collections.singletonList(new EquivalentAddressGroup( Arrays.asList(new SocketAddress() {}, new SocketAddress() {}))), Attributes.EMPTY); assertThat(getStats(channel).channelTrace.events).hasSize(prevSize); prevSize = getStats(channel).channelTrace.events.size(); nameResolverFactory.resolvers.get(0).listener.onError(Status.INTERNAL); assertThat(getStats(channel).channelTrace.events).hasSize(prevSize + 1); prevSize = getStats(channel).channelTrace.events.size(); nameResolverFactory.resolvers.get(0).listener.onError(Status.INTERNAL); assertThat(getStats(channel).channelTrace.events).hasSize(prevSize); prevSize = getStats(channel).channelTrace.events.size(); nameResolverFactory.resolvers.get(0).listener.onAddresses( Collections.singletonList(new EquivalentAddressGroup( Arrays.asList(new SocketAddress() {}, new SocketAddress() {}))), Attributes.EMPTY); assertThat(getStats(channel).channelTrace.events).hasSize(prevSize + 1); }
@Override public ListenableFuture<ChannelStats> getStats() { final SettableFuture<ChannelStats> ret = SettableFuture.create(); final class StatsFetcher implements Runnable { @Override public void run() { ChannelStats.Builder builder = new ChannelStats.Builder(); channelCallTracer.updateBuilder(builder); channelTracer.updateBuilder(builder); builder.setTarget(target).setState(channelStateManager.getState()); List<InternalWithLogId> children = new ArrayList<>(); children.addAll(subchannels); children.addAll(oobChannels); builder.setSubchannels(children); ret.set(builder.build()); } } syncContext.execute(new StatsFetcher()); return ret; }
ManagedChannelImpl extends ManagedChannel implements
    InternalInstrumented<ChannelStats> { @Override public ListenableFuture<ChannelStats> getStats() { final SettableFuture<ChannelStats> ret = SettableFuture.create(); final class StatsFetcher implements Runnable { @Override public void run() { ChannelStats.Builder builder = new ChannelStats.Builder(); channelCallTracer.updateBuilder(builder); channelTracer.updateBuilder(builder); builder.setTarget(target).setState(channelStateManager.getState()); List<InternalWithLogId> children = new ArrayList<>(); children.addAll(subchannels); children.addAll(oobChannels); builder.setSubchannels(children); ret.set(builder.build()); } } syncContext.execute(new StatsFetcher()); return ret; } }
ManagedChannelImpl extends ManagedChannel implements
    InternalInstrumented<ChannelStats> { @Override public ListenableFuture<ChannelStats> getStats() { final SettableFuture<ChannelStats> ret = SettableFuture.create(); final class StatsFetcher implements Runnable { @Override public void run() { ChannelStats.Builder builder = new ChannelStats.Builder(); channelCallTracer.updateBuilder(builder); channelTracer.updateBuilder(builder); builder.setTarget(target).setState(channelStateManager.getState()); List<InternalWithLogId> children = new ArrayList<>(); children.addAll(subchannels); children.addAll(oobChannels); builder.setSubchannels(children); ret.set(builder.build()); } } syncContext.execute(new StatsFetcher()); return ret; } ManagedChannelImpl(
      AbstractManagedChannelImplBuilder<?> builder,
      ClientTransportFactory clientTransportFactory,
      BackoffPolicy.Provider backoffPolicyProvider,
      ObjectPool<? extends Executor> balancerRpcExecutorPool,
      Supplier<Stopwatch> stopwatchSupplier,
      List<ClientInterceptor> interceptors,
      final TimeProvider timeProvider); }
ManagedChannelImpl extends ManagedChannel implements
    InternalInstrumented<ChannelStats> { @Override public ListenableFuture<ChannelStats> getStats() { final SettableFuture<ChannelStats> ret = SettableFuture.create(); final class StatsFetcher implements Runnable { @Override public void run() { ChannelStats.Builder builder = new ChannelStats.Builder(); channelCallTracer.updateBuilder(builder); channelTracer.updateBuilder(builder); builder.setTarget(target).setState(channelStateManager.getState()); List<InternalWithLogId> children = new ArrayList<>(); children.addAll(subchannels); children.addAll(oobChannels); builder.setSubchannels(children); ret.set(builder.build()); } } syncContext.execute(new StatsFetcher()); return ret; } ManagedChannelImpl(
      AbstractManagedChannelImplBuilder<?> builder,
      ClientTransportFactory clientTransportFactory,
      BackoffPolicy.Provider backoffPolicyProvider,
      ObjectPool<? extends Executor> balancerRpcExecutorPool,
      Supplier<Stopwatch> stopwatchSupplier,
      List<ClientInterceptor> interceptors,
      final TimeProvider timeProvider); @Override ListenableFuture<ChannelStats> getStats(); @Override InternalLogId getLogId(); @Override ManagedChannelImpl shutdown(); @Override ManagedChannelImpl shutdownNow(); @Override boolean isShutdown(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override boolean isTerminated(); @Override ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method,
      CallOptions callOptions); @Override String authority(); @Override ConnectivityState getState(boolean requestConnection); @Override void notifyWhenStateChanged(final ConnectivityState source, final Runnable callback); @Override void resetConnectBackoff(); @Override void enterIdle(); @Override String toString(); @Override Map<String, String> getLoadBalanceModeMap(); @Override void setLoadBalanceModeMap(Map<String, String> map); @Override NameResolver getNameResolver(); @Override LoadBalancer getLoadBalancer(); }
ManagedChannelImpl extends ManagedChannel implements
    InternalInstrumented<ChannelStats> { @Override public ListenableFuture<ChannelStats> getStats() { final SettableFuture<ChannelStats> ret = SettableFuture.create(); final class StatsFetcher implements Runnable { @Override public void run() { ChannelStats.Builder builder = new ChannelStats.Builder(); channelCallTracer.updateBuilder(builder); channelTracer.updateBuilder(builder); builder.setTarget(target).setState(channelStateManager.getState()); List<InternalWithLogId> children = new ArrayList<>(); children.addAll(subchannels); children.addAll(oobChannels); builder.setSubchannels(children); ret.set(builder.build()); } } syncContext.execute(new StatsFetcher()); return ret; } ManagedChannelImpl(
      AbstractManagedChannelImplBuilder<?> builder,
      ClientTransportFactory clientTransportFactory,
      BackoffPolicy.Provider backoffPolicyProvider,
      ObjectPool<? extends Executor> balancerRpcExecutorPool,
      Supplier<Stopwatch> stopwatchSupplier,
      List<ClientInterceptor> interceptors,
      final TimeProvider timeProvider); @Override ListenableFuture<ChannelStats> getStats(); @Override InternalLogId getLogId(); @Override ManagedChannelImpl shutdown(); @Override ManagedChannelImpl shutdownNow(); @Override boolean isShutdown(); @Override boolean awaitTermination(long timeout, TimeUnit unit); @Override boolean isTerminated(); @Override ClientCall<ReqT, RespT> newCall(MethodDescriptor<ReqT, RespT> method,
      CallOptions callOptions); @Override String authority(); @Override ConnectivityState getState(boolean requestConnection); @Override void notifyWhenStateChanged(final ConnectivityState source, final Runnable callback); @Override void resetConnectBackoff(); @Override void enterIdle(); @Override String toString(); @Override Map<String, String> getLoadBalanceModeMap(); @Override void setLoadBalanceModeMap(Map<String, String> map); @Override NameResolver getNameResolver(); @Override LoadBalancer getLoadBalancer();  }