|  | @@ -67,7 +67,6 @@
 | 
	
		
			
				|  |  |  #include "src/core/lib/transport/status_metadata.h"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  using grpc_core::internal::ClientChannelMethodParsedObject;
 | 
	
		
			
				|  |  | -using grpc_core::internal::ProcessedResolverResult;
 | 
	
		
			
				|  |  |  using grpc_core::internal::ServerRetryThrottleData;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  //
 | 
	
	
		
			
				|  | @@ -223,8 +222,9 @@ class ChannelData {
 | 
	
		
			
				|  |  |    ~ChannelData();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    static bool ProcessResolverResultLocked(
 | 
	
		
			
				|  |  | -      void* arg, const Resolver::Result& result, const char** lb_policy_name,
 | 
	
		
			
				|  |  | -      RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config);
 | 
	
		
			
				|  |  | +      void* arg, Resolver::Result* result, const char** lb_policy_name,
 | 
	
		
			
				|  |  | +      RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config,
 | 
	
		
			
				|  |  | +      grpc_error** service_config_error);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    grpc_error* DoPingLocked(grpc_transport_op* op);
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -232,6 +232,12 @@ class ChannelData {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    static void TryToConnectLocked(void* arg, grpc_error* error_ignored);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +  void ProcessLbPolicy(
 | 
	
		
			
				|  |  | +      const Resolver::Result& resolver_result,
 | 
	
		
			
				|  |  | +      const internal::ClientChannelGlobalParsedObject* parsed_service_config,
 | 
	
		
			
				|  |  | +      UniquePtr<char>* lb_policy_name,
 | 
	
		
			
				|  |  | +      RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |    //
 | 
	
		
			
				|  |  |    // Fields set at construction and never modified.
 | 
	
		
			
				|  |  |    //
 | 
	
	
		
			
				|  | @@ -241,6 +247,7 @@ class ChannelData {
 | 
	
		
			
				|  |  |    grpc_channel_stack* owning_stack_;
 | 
	
		
			
				|  |  |    ClientChannelFactory* client_channel_factory_;
 | 
	
		
			
				|  |  |    UniquePtr<char> server_name_;
 | 
	
		
			
				|  |  | +  RefCountedPtr<ServiceConfig> default_service_config_;
 | 
	
		
			
				|  |  |    // Initialized shortly after construction.
 | 
	
		
			
				|  |  |    channelz::ClientChannelNode* channelz_node_ = nullptr;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -264,7 +271,8 @@ class ChannelData {
 | 
	
		
			
				|  |  |    OrphanablePtr<LoadBalancingPolicy> resolving_lb_policy_;
 | 
	
		
			
				|  |  |    grpc_connectivity_state_tracker state_tracker_;
 | 
	
		
			
				|  |  |    ExternalConnectivityWatcher::WatcherList external_connectivity_watcher_list_;
 | 
	
		
			
				|  |  | -  UniquePtr<char> health_check_service_name_;
 | 
	
		
			
				|  |  | +  RefCountedPtr<ServiceConfig> saved_service_config_;
 | 
	
		
			
				|  |  | +  bool received_first_resolver_result_ = false;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    //
 | 
	
		
			
				|  |  |    // Fields accessed from both data plane and control plane combiners.
 | 
	
	
		
			
				|  | @@ -942,18 +950,10 @@ class ChannelData::ClientChannelControlHelper
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    Subchannel* CreateSubchannel(const grpc_channel_args& args) override {
 | 
	
		
			
				|  |  | -    grpc_arg args_to_add[2];
 | 
	
		
			
				|  |  | -    int num_args_to_add = 0;
 | 
	
		
			
				|  |  | -    if (chand_->health_check_service_name_ != nullptr) {
 | 
	
		
			
				|  |  | -      args_to_add[0] = grpc_channel_arg_string_create(
 | 
	
		
			
				|  |  | -          const_cast<char*>("grpc.temp.health_check"),
 | 
	
		
			
				|  |  | -          const_cast<char*>(chand_->health_check_service_name_.get()));
 | 
	
		
			
				|  |  | -      num_args_to_add++;
 | 
	
		
			
				|  |  | -    }
 | 
	
		
			
				|  |  | -    args_to_add[num_args_to_add++] = SubchannelPoolInterface::CreateChannelArg(
 | 
	
		
			
				|  |  | +    grpc_arg arg = SubchannelPoolInterface::CreateChannelArg(
 | 
	
		
			
				|  |  |          chand_->subchannel_pool_.get());
 | 
	
		
			
				|  |  |      grpc_channel_args* new_args =
 | 
	
		
			
				|  |  | -        grpc_channel_args_copy_and_add(&args, args_to_add, num_args_to_add);
 | 
	
		
			
				|  |  | +        grpc_channel_args_copy_and_add(&args, &arg, 1);
 | 
	
		
			
				|  |  |      Subchannel* subchannel =
 | 
	
		
			
				|  |  |          chand_->client_channel_factory_->CreateSubchannel(new_args);
 | 
	
		
			
				|  |  |      grpc_channel_args_destroy(new_args);
 | 
	
	
		
			
				|  | @@ -970,7 +970,7 @@ class ChannelData::ClientChannelControlHelper
 | 
	
		
			
				|  |  |        UniquePtr<LoadBalancingPolicy::SubchannelPicker> picker) override {
 | 
	
		
			
				|  |  |      grpc_error* disconnect_error =
 | 
	
		
			
				|  |  |          chand_->disconnect_error_.Load(MemoryOrder::ACQUIRE);
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  |        const char* extra = disconnect_error == GRPC_ERROR_NONE
 | 
	
		
			
				|  |  |                                ? ""
 | 
	
		
			
				|  |  |                                : " (ignoring -- channel shutting down)";
 | 
	
	
		
			
				|  | @@ -1066,6 +1066,19 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error)
 | 
	
		
			
				|  |  |          "filter");
 | 
	
		
			
				|  |  |      return;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | +  // Get default service config
 | 
	
		
			
				|  |  | +  const char* service_config_json = grpc_channel_arg_get_string(
 | 
	
		
			
				|  |  | +      grpc_channel_args_find(args->channel_args, GRPC_ARG_SERVICE_CONFIG));
 | 
	
		
			
				|  |  | +  // TODO(yashkt): Make sure we set the channel in TRANSIENT_FAILURE on an
 | 
	
		
			
				|  |  | +  // invalid default service config
 | 
	
		
			
				|  |  | +  if (service_config_json != nullptr) {
 | 
	
		
			
				|  |  | +    *error = GRPC_ERROR_NONE;
 | 
	
		
			
				|  |  | +    default_service_config_ = ServiceConfig::Create(service_config_json, error);
 | 
	
		
			
				|  |  | +    if (*error != GRPC_ERROR_NONE) {
 | 
	
		
			
				|  |  | +      default_service_config_.reset();
 | 
	
		
			
				|  |  | +      return;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  |    grpc_uri* uri = grpc_uri_parse(server_uri, true);
 | 
	
		
			
				|  |  |    if (uri != nullptr && uri->path[0] != '\0') {
 | 
	
		
			
				|  |  |      server_name_.reset(
 | 
	
	
		
			
				|  | @@ -1105,7 +1118,7 @@ ChannelData::ChannelData(grpc_channel_element_args* args, grpc_error** error)
 | 
	
		
			
				|  |  |    } else {
 | 
	
		
			
				|  |  |      grpc_pollset_set_add_pollset_set(resolving_lb_policy_->interested_parties(),
 | 
	
		
			
				|  |  |                                       interested_parties_);
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO, "chand=%p: created resolving_lb_policy=%p", this,
 | 
	
		
			
				|  |  |                resolving_lb_policy_.get());
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1128,40 +1141,172 @@ ChannelData::~ChannelData() {
 | 
	
		
			
				|  |  |    gpr_mu_destroy(&info_mu_);
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +void ChannelData::ProcessLbPolicy(
 | 
	
		
			
				|  |  | +    const Resolver::Result& resolver_result,
 | 
	
		
			
				|  |  | +    const internal::ClientChannelGlobalParsedObject* parsed_service_config,
 | 
	
		
			
				|  |  | +    UniquePtr<char>* lb_policy_name,
 | 
	
		
			
				|  |  | +    RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config) {
 | 
	
		
			
				|  |  | +  // Prefer the LB policy name found in the service config.
 | 
	
		
			
				|  |  | +  if (parsed_service_config != nullptr &&
 | 
	
		
			
				|  |  | +      parsed_service_config->parsed_lb_config() != nullptr) {
 | 
	
		
			
				|  |  | +    lb_policy_name->reset(
 | 
	
		
			
				|  |  | +        gpr_strdup(parsed_service_config->parsed_lb_config()->name()));
 | 
	
		
			
				|  |  | +    *lb_policy_config = parsed_service_config->parsed_lb_config();
 | 
	
		
			
				|  |  | +    return;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  const char* local_policy_name = nullptr;
 | 
	
		
			
				|  |  | +  if (parsed_service_config != nullptr &&
 | 
	
		
			
				|  |  | +      parsed_service_config->parsed_deprecated_lb_policy() != nullptr) {
 | 
	
		
			
				|  |  | +    local_policy_name = parsed_service_config->parsed_deprecated_lb_policy();
 | 
	
		
			
				|  |  | +  } else {
 | 
	
		
			
				|  |  | +    const grpc_arg* channel_arg =
 | 
	
		
			
				|  |  | +        grpc_channel_args_find(resolver_result.args, GRPC_ARG_LB_POLICY_NAME);
 | 
	
		
			
				|  |  | +    local_policy_name = grpc_channel_arg_get_string(channel_arg);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  // Special case: If at least one balancer address is present, we use
 | 
	
		
			
				|  |  | +  // the grpclb policy, regardless of what the resolver has returned.
 | 
	
		
			
				|  |  | +  bool found_balancer_address = false;
 | 
	
		
			
				|  |  | +  for (size_t i = 0; i < resolver_result.addresses.size(); ++i) {
 | 
	
		
			
				|  |  | +    const ServerAddress& address = resolver_result.addresses[i];
 | 
	
		
			
				|  |  | +    if (address.IsBalancer()) {
 | 
	
		
			
				|  |  | +      found_balancer_address = true;
 | 
	
		
			
				|  |  | +      break;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  if (found_balancer_address) {
 | 
	
		
			
				|  |  | +    if (local_policy_name != nullptr &&
 | 
	
		
			
				|  |  | +        strcmp(local_policy_name, "grpclb") != 0) {
 | 
	
		
			
				|  |  | +      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  | +              "resolver requested LB policy %s but provided at least one "
 | 
	
		
			
				|  |  | +              "balancer address -- forcing use of grpclb LB policy",
 | 
	
		
			
				|  |  | +              local_policy_name);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    local_policy_name = "grpclb";
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  // Use pick_first if nothing was specified and we didn't select grpclb
 | 
	
		
			
				|  |  | +  // above.
 | 
	
		
			
				|  |  | +  lb_policy_name->reset(gpr_strdup(
 | 
	
		
			
				|  |  | +      local_policy_name == nullptr ? "pick_first" : local_policy_name));
 | 
	
		
			
				|  |  | +}
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |  // Synchronous callback from ResolvingLoadBalancingPolicy to process a
 | 
	
		
			
				|  |  |  // resolver result update.
 | 
	
		
			
				|  |  |  bool ChannelData::ProcessResolverResultLocked(
 | 
	
		
			
				|  |  | -    void* arg, const Resolver::Result& result, const char** lb_policy_name,
 | 
	
		
			
				|  |  | -    RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config) {
 | 
	
		
			
				|  |  | +    void* arg, Resolver::Result* result, const char** lb_policy_name,
 | 
	
		
			
				|  |  | +    RefCountedPtr<ParsedLoadBalancingConfig>* lb_policy_config,
 | 
	
		
			
				|  |  | +    grpc_error** service_config_error) {
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(arg);
 | 
	
		
			
				|  |  | -  ProcessedResolverResult resolver_result(result);
 | 
	
		
			
				|  |  | -  char* service_config_json = gpr_strdup(resolver_result.service_config_json());
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | -    gpr_log(GPR_INFO, "chand=%p: resolver returned service config: \"%s\"",
 | 
	
		
			
				|  |  | -            chand, service_config_json);
 | 
	
		
			
				|  |  | -  }
 | 
	
		
			
				|  |  | -  chand->health_check_service_name_.reset(
 | 
	
		
			
				|  |  | -      gpr_strdup(resolver_result.health_check_service_name()));
 | 
	
		
			
				|  |  | -  // Create service config setter to update channel state in the data
 | 
	
		
			
				|  |  | -  // plane combiner.  Destroys itself when done.
 | 
	
		
			
				|  |  | -  New<ServiceConfigSetter>(chand, resolver_result.retry_throttle_data(),
 | 
	
		
			
				|  |  | -                           resolver_result.service_config());
 | 
	
		
			
				|  |  | +  RefCountedPtr<ServiceConfig> service_config;
 | 
	
		
			
				|  |  | +  // If resolver did not return a service config or returned an invalid service
 | 
	
		
			
				|  |  | +  // config, we need a fallback service config.
 | 
	
		
			
				|  |  | +  if (result->service_config_error != GRPC_ERROR_NONE) {
 | 
	
		
			
				|  |  | +    // If the service config was invalid, then fallback to the saved service
 | 
	
		
			
				|  |  | +    // config. If there is no saved config either, use the default service
 | 
	
		
			
				|  |  | +    // config.
 | 
	
		
			
				|  |  | +    if (chand->saved_service_config_ != nullptr) {
 | 
	
		
			
				|  |  | +      service_config = chand->saved_service_config_;
 | 
	
		
			
				|  |  | +      if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  | +        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  | +                "chand=%p: resolver returned invalid service config. "
 | 
	
		
			
				|  |  | +                "Continuing to use previous service config.",
 | 
	
		
			
				|  |  | +                chand);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +    } else if (chand->default_service_config_ != nullptr) {
 | 
	
		
			
				|  |  | +      if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  | +        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  | +                "chand=%p: resolver returned invalid service config. Using "
 | 
	
		
			
				|  |  | +                "default service config provided by client API.",
 | 
	
		
			
				|  |  | +                chand);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      service_config = chand->default_service_config_;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  } else if (result->service_config == nullptr) {
 | 
	
		
			
				|  |  | +    if (chand->default_service_config_ != nullptr) {
 | 
	
		
			
				|  |  | +      if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  | +        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  | +                "chand=%p: resolver returned no service config. Using default "
 | 
	
		
			
				|  |  | +                "service config provided by client API.",
 | 
	
		
			
				|  |  | +                chand);
 | 
	
		
			
				|  |  | +      }
 | 
	
		
			
				|  |  | +      service_config = chand->default_service_config_;
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +  } else {
 | 
	
		
			
				|  |  | +    service_config = result->service_config;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  *service_config_error = GRPC_ERROR_REF(result->service_config_error);
 | 
	
		
			
				|  |  | +  if (service_config == nullptr &&
 | 
	
		
			
				|  |  | +      result->service_config_error != GRPC_ERROR_NONE) {
 | 
	
		
			
				|  |  | +    return false;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  // Process service config.
 | 
	
		
			
				|  |  | +  UniquePtr<char> service_config_json;
 | 
	
		
			
				|  |  | +  const internal::ClientChannelGlobalParsedObject* parsed_service_config =
 | 
	
		
			
				|  |  | +      nullptr;
 | 
	
		
			
				|  |  | +  if (service_config != nullptr) {
 | 
	
		
			
				|  |  | +    parsed_service_config =
 | 
	
		
			
				|  |  | +        static_cast<const internal::ClientChannelGlobalParsedObject*>(
 | 
	
		
			
				|  |  | +            service_config->GetParsedGlobalServiceConfigObject(
 | 
	
		
			
				|  |  | +                internal::ClientChannelServiceConfigParser::ParserIndex()));
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  // TODO(roth): Eliminate this hack as part of hiding health check
 | 
	
		
			
				|  |  | +  // service name from LB policy API.  As part of this, change the API
 | 
	
		
			
				|  |  | +  // for this function to pass in result as a const reference.
 | 
	
		
			
				|  |  | +  if (parsed_service_config != nullptr &&
 | 
	
		
			
				|  |  | +      parsed_service_config->health_check_service_name() != nullptr) {
 | 
	
		
			
				|  |  | +    grpc_arg new_arg = grpc_channel_arg_string_create(
 | 
	
		
			
				|  |  | +        const_cast<char*>("grpc.temp.health_check"),
 | 
	
		
			
				|  |  | +        const_cast<char*>(parsed_service_config->health_check_service_name()));
 | 
	
		
			
				|  |  | +    grpc_channel_args* new_args =
 | 
	
		
			
				|  |  | +        grpc_channel_args_copy_and_add(result->args, &new_arg, 1);
 | 
	
		
			
				|  |  | +    grpc_channel_args_destroy(result->args);
 | 
	
		
			
				|  |  | +    result->args = new_args;
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  // Check if the config has changed.
 | 
	
		
			
				|  |  | +  const bool service_config_changed =
 | 
	
		
			
				|  |  | +      ((service_config == nullptr) !=
 | 
	
		
			
				|  |  | +       (chand->saved_service_config_ == nullptr)) ||
 | 
	
		
			
				|  |  | +      (service_config != nullptr &&
 | 
	
		
			
				|  |  | +       strcmp(service_config->service_config_json(),
 | 
	
		
			
				|  |  | +              chand->saved_service_config_->service_config_json()) != 0);
 | 
	
		
			
				|  |  | +  if (service_config_changed) {
 | 
	
		
			
				|  |  | +    service_config_json.reset(gpr_strdup(
 | 
	
		
			
				|  |  | +        service_config != nullptr ? service_config->service_config_json()
 | 
	
		
			
				|  |  | +                                  : ""));
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  | +      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  | +              "chand=%p: resolver returned updated service config: \"%s\"",
 | 
	
		
			
				|  |  | +              chand, service_config_json.get());
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    chand->saved_service_config_ = std::move(service_config);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  // We want to set the service config at least once. This should not really be
 | 
	
		
			
				|  |  | +  // needed, but we are doing it as a defensive approach. This can be removed,
 | 
	
		
			
				|  |  | +  // if we feel it is unnecessary.
 | 
	
		
			
				|  |  | +  if (service_config_changed || !chand->received_first_resolver_result_) {
 | 
	
		
			
				|  |  | +    chand->received_first_resolver_result_ = true;
 | 
	
		
			
				|  |  | +    Optional<internal::ClientChannelGlobalParsedObject::RetryThrottling>
 | 
	
		
			
				|  |  | +        retry_throttle_data;
 | 
	
		
			
				|  |  | +    if (parsed_service_config != nullptr) {
 | 
	
		
			
				|  |  | +      retry_throttle_data = parsed_service_config->retry_throttling();
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +    // Create service config setter to update channel state in the data
 | 
	
		
			
				|  |  | +    // plane combiner.  Destroys itself when done.
 | 
	
		
			
				|  |  | +    New<ServiceConfigSetter>(chand, retry_throttle_data,
 | 
	
		
			
				|  |  | +                             chand->saved_service_config_);
 | 
	
		
			
				|  |  | +  }
 | 
	
		
			
				|  |  | +  UniquePtr<char> processed_lb_policy_name;
 | 
	
		
			
				|  |  | +  chand->ProcessLbPolicy(*result, parsed_service_config,
 | 
	
		
			
				|  |  | +                         &processed_lb_policy_name, lb_policy_config);
 | 
	
		
			
				|  |  |    // Swap out the data used by GetChannelInfo().
 | 
	
		
			
				|  |  | -  bool service_config_changed;
 | 
	
		
			
				|  |  |    {
 | 
	
		
			
				|  |  |      MutexLock lock(&chand->info_mu_);
 | 
	
		
			
				|  |  | -    chand->info_lb_policy_name_ = resolver_result.lb_policy_name();
 | 
	
		
			
				|  |  | -    service_config_changed =
 | 
	
		
			
				|  |  | -        ((service_config_json == nullptr) !=
 | 
	
		
			
				|  |  | -         (chand->info_service_config_json_ == nullptr)) ||
 | 
	
		
			
				|  |  | -        (service_config_json != nullptr &&
 | 
	
		
			
				|  |  | -         strcmp(service_config_json, chand->info_service_config_json_.get()) !=
 | 
	
		
			
				|  |  | -             0);
 | 
	
		
			
				|  |  | -    chand->info_service_config_json_.reset(service_config_json);
 | 
	
		
			
				|  |  | +    chand->info_lb_policy_name_ = std::move(processed_lb_policy_name);
 | 
	
		
			
				|  |  | +    if (service_config_json != nullptr) {
 | 
	
		
			
				|  |  | +      chand->info_service_config_json_ = std::move(service_config_json);
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Return results.
 | 
	
		
			
				|  |  |    *lb_policy_name = chand->info_lb_policy_name_.get();
 | 
	
		
			
				|  |  | -  *lb_policy_config = resolver_result.lb_policy_config();
 | 
	
		
			
				|  |  |    return service_config_changed;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -1407,7 +1552,7 @@ void CallData::StartTransportStreamOpBatch(
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // If we've previously been cancelled, immediately fail any new batches.
 | 
	
		
			
				|  |  |    if (GPR_UNLIKELY(calld->cancel_error_ != GRPC_ERROR_NONE)) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO, "chand=%p calld=%p: failing batch with error: %s",
 | 
	
		
			
				|  |  |                chand, calld, grpc_error_string(calld->cancel_error_));
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1426,7 +1571,7 @@ void CallData::StartTransportStreamOpBatch(
 | 
	
		
			
				|  |  |      GRPC_ERROR_UNREF(calld->cancel_error_);
 | 
	
		
			
				|  |  |      calld->cancel_error_ =
 | 
	
		
			
				|  |  |          GRPC_ERROR_REF(batch->payload->cancel_stream.cancel_error);
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO, "chand=%p calld=%p: recording cancel_error=%s", chand,
 | 
	
		
			
				|  |  |                calld, grpc_error_string(calld->cancel_error_));
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1454,7 +1599,7 @@ void CallData::StartTransportStreamOpBatch(
 | 
	
		
			
				|  |  |    // the channel combiner, which is more efficient (especially for
 | 
	
		
			
				|  |  |    // streaming calls).
 | 
	
		
			
				|  |  |    if (calld->subchannel_call_ != nullptr) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: starting batch on subchannel_call=%p", chand,
 | 
	
		
			
				|  |  |                calld, calld->subchannel_call_.get());
 | 
	
	
		
			
				|  | @@ -1466,7 +1611,7 @@ void CallData::StartTransportStreamOpBatch(
 | 
	
		
			
				|  |  |    // For batches containing a send_initial_metadata op, enter the channel
 | 
	
		
			
				|  |  |    // combiner to start a pick.
 | 
	
		
			
				|  |  |    if (GPR_LIKELY(batch->send_initial_metadata)) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO, "chand=%p calld=%p: entering client_channel combiner",
 | 
	
		
			
				|  |  |                chand, calld);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1477,7 +1622,7 @@ void CallData::StartTransportStreamOpBatch(
 | 
	
		
			
				|  |  |          GRPC_ERROR_NONE);
 | 
	
		
			
				|  |  |    } else {
 | 
	
		
			
				|  |  |      // For all other batches, release the call combiner.
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: saved batch, yielding call combiner", chand,
 | 
	
		
			
				|  |  |                calld);
 | 
	
	
		
			
				|  | @@ -1535,7 +1680,7 @@ void CallData::MaybeCacheSendOpsForBatch(PendingBatch* pending) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void CallData::FreeCachedSendInitialMetadata(ChannelData* chand) {
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: destroying calld->send_initial_metadata", chand,
 | 
	
		
			
				|  |  |              this);
 | 
	
	
		
			
				|  | @@ -1544,7 +1689,7 @@ void CallData::FreeCachedSendInitialMetadata(ChannelData* chand) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void CallData::FreeCachedSendMessage(ChannelData* chand, size_t idx) {
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: destroying calld->send_messages[%" PRIuPTR "]",
 | 
	
		
			
				|  |  |              chand, this, idx);
 | 
	
	
		
			
				|  | @@ -1553,7 +1698,7 @@ void CallData::FreeCachedSendMessage(ChannelData* chand, size_t idx) {
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void CallData::FreeCachedSendTrailingMetadata(ChannelData* chand) {
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: destroying calld->send_trailing_metadata",
 | 
	
		
			
				|  |  |              chand, this);
 | 
	
	
		
			
				|  | @@ -1630,7 +1775,7 @@ void CallData::PendingBatchesAdd(grpc_call_element* elem,
 | 
	
		
			
				|  |  |                                   grpc_transport_stream_op_batch* batch) {
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  |    const size_t idx = GetBatchIndex(batch);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: adding pending batch at index %" PRIuPTR, chand,
 | 
	
		
			
				|  |  |              this, idx);
 | 
	
	
		
			
				|  | @@ -1659,7 +1804,7 @@ void CallData::PendingBatchesAdd(grpc_call_element* elem,
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      if (GPR_UNLIKELY(bytes_buffered_for_retry_ >
 | 
	
		
			
				|  |  |                       chand->per_rpc_retry_buffer_size())) {
 | 
	
		
			
				|  |  | -      if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +      if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |          gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                  "chand=%p calld=%p: exceeded retry buffer size, committing",
 | 
	
		
			
				|  |  |                  chand, this);
 | 
	
	
		
			
				|  | @@ -1672,7 +1817,7 @@ void CallData::PendingBatchesAdd(grpc_call_element* elem,
 | 
	
		
			
				|  |  |        // If we are not going to retry and have not yet started, pretend
 | 
	
		
			
				|  |  |        // retries are disabled so that we don't bother with retry overhead.
 | 
	
		
			
				|  |  |        if (num_attempts_completed_ == 0) {
 | 
	
		
			
				|  |  | -        if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +        if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |            gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                    "chand=%p calld=%p: disabling retries before first attempt",
 | 
	
		
			
				|  |  |                    chand, this);
 | 
	
	
		
			
				|  | @@ -1713,7 +1858,7 @@ void CallData::MaybeClearPendingBatch(grpc_call_element* elem,
 | 
	
		
			
				|  |  |        (!batch->recv_trailing_metadata ||
 | 
	
		
			
				|  |  |         batch->payload->recv_trailing_metadata.recv_trailing_metadata_ready ==
 | 
	
		
			
				|  |  |             nullptr)) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO, "chand=%p calld=%p: clearing pending batch", chand,
 | 
	
		
			
				|  |  |                this);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1736,7 +1881,7 @@ void CallData::PendingBatchesFail(
 | 
	
		
			
				|  |  |      grpc_call_element* elem, grpc_error* error,
 | 
	
		
			
				|  |  |      YieldCallCombinerPredicate yield_call_combiner_predicate) {
 | 
	
		
			
				|  |  |    GPR_ASSERT(error != GRPC_ERROR_NONE);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      size_t num_batches = 0;
 | 
	
		
			
				|  |  |      for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
 | 
	
		
			
				|  |  |        if (pending_batches_[i].batch != nullptr) ++num_batches;
 | 
	
	
		
			
				|  | @@ -1790,7 +1935,7 @@ void CallData::PendingBatchesResume(grpc_call_element* elem) {
 | 
	
		
			
				|  |  |      return;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Retries not enabled; send down batches as-is.
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      size_t num_batches = 0;
 | 
	
		
			
				|  |  |      for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
 | 
	
		
			
				|  |  |        if (pending_batches_[i].batch != nullptr) ++num_batches;
 | 
	
	
		
			
				|  | @@ -1831,7 +1976,7 @@ CallData::PendingBatch* CallData::PendingBatchFind(grpc_call_element* elem,
 | 
	
		
			
				|  |  |      PendingBatch* pending = &pending_batches_[i];
 | 
	
		
			
				|  |  |      grpc_transport_stream_op_batch* batch = pending->batch;
 | 
	
		
			
				|  |  |      if (batch != nullptr && predicate(batch)) {
 | 
	
		
			
				|  |  | -      if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +      if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |          gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                  "chand=%p calld=%p: %s pending batch at index %" PRIuPTR, chand,
 | 
	
		
			
				|  |  |                  this, log_message, i);
 | 
	
	
		
			
				|  | @@ -1851,7 +1996,7 @@ void CallData::RetryCommit(grpc_call_element* elem,
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  |    if (retry_committed_) return;
 | 
	
		
			
				|  |  |    retry_committed_ = true;
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: committing retries", chand, this);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    if (retry_state != nullptr) {
 | 
	
	
		
			
				|  | @@ -1886,7 +2031,7 @@ void CallData::DoRetry(grpc_call_element* elem,
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      next_attempt_time = retry_backoff_->NextAttemptTime();
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: retrying failed call in %" PRId64 " ms", chand,
 | 
	
		
			
				|  |  |              this, next_attempt_time - ExecCtx::Get()->Now());
 | 
	
	
		
			
				|  | @@ -1916,7 +2061,7 @@ bool CallData::MaybeRetry(grpc_call_element* elem,
 | 
	
		
			
				|  |  |      retry_state = static_cast<SubchannelCallRetryState*>(
 | 
	
		
			
				|  |  |          batch_data->subchannel_call->GetParentData());
 | 
	
		
			
				|  |  |      if (retry_state->retry_dispatched) {
 | 
	
		
			
				|  |  | -      if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +      if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |          gpr_log(GPR_INFO, "chand=%p calld=%p: retry already dispatched", chand,
 | 
	
		
			
				|  |  |                  this);
 | 
	
		
			
				|  |  |        }
 | 
	
	
		
			
				|  | @@ -1928,14 +2073,14 @@ bool CallData::MaybeRetry(grpc_call_element* elem,
 | 
	
		
			
				|  |  |      if (retry_throttle_data_ != nullptr) {
 | 
	
		
			
				|  |  |        retry_throttle_data_->RecordSuccess();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO, "chand=%p calld=%p: call succeeded", chand, this);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      return false;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Status is not OK.  Check whether the status is retryable.
 | 
	
		
			
				|  |  |    if (!retry_policy->retryable_status_codes.Contains(status)) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: status %s not configured as retryable", chand,
 | 
	
		
			
				|  |  |                this, grpc_status_code_to_string(status));
 | 
	
	
		
			
				|  | @@ -1951,14 +2096,14 @@ bool CallData::MaybeRetry(grpc_call_element* elem,
 | 
	
		
			
				|  |  |    // checks, so that we don't fail to record failures due to other factors.
 | 
	
		
			
				|  |  |    if (retry_throttle_data_ != nullptr &&
 | 
	
		
			
				|  |  |        !retry_throttle_data_->RecordFailure()) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO, "chand=%p calld=%p: retries throttled", chand, this);
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |      return false;
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // Check whether the call is committed.
 | 
	
		
			
				|  |  |    if (retry_committed_) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO, "chand=%p calld=%p: retries already committed", chand,
 | 
	
		
			
				|  |  |                this);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1967,7 +2112,7 @@ bool CallData::MaybeRetry(grpc_call_element* elem,
 | 
	
		
			
				|  |  |    // Check whether we have retries remaining.
 | 
	
		
			
				|  |  |    ++num_attempts_completed_;
 | 
	
		
			
				|  |  |    if (num_attempts_completed_ >= retry_policy->max_attempts) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO, "chand=%p calld=%p: exceeded %d retry attempts", chand,
 | 
	
		
			
				|  |  |                this, retry_policy->max_attempts);
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -1975,7 +2120,7 @@ bool CallData::MaybeRetry(grpc_call_element* elem,
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    // If the call was cancelled from the surface, don't retry.
 | 
	
		
			
				|  |  |    if (cancel_error_ != GRPC_ERROR_NONE) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: call cancelled from surface, not retrying",
 | 
	
		
			
				|  |  |                chand, this);
 | 
	
	
		
			
				|  | @@ -1988,14 +2133,14 @@ bool CallData::MaybeRetry(grpc_call_element* elem,
 | 
	
		
			
				|  |  |      // If the value is "-1" or any other unparseable string, we do not retry.
 | 
	
		
			
				|  |  |      uint32_t ms;
 | 
	
		
			
				|  |  |      if (!grpc_parse_slice_to_uint32(GRPC_MDVALUE(*server_pushback_md), &ms)) {
 | 
	
		
			
				|  |  | -      if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +      if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |          gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                  "chand=%p calld=%p: not retrying due to server push-back",
 | 
	
		
			
				|  |  |                  chand, this);
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |        return false;
 | 
	
		
			
				|  |  |      } else {
 | 
	
		
			
				|  |  | -      if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +      if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |          gpr_log(GPR_INFO, "chand=%p calld=%p: server push-back: retry in %u ms",
 | 
	
		
			
				|  |  |                  chand, this, ms);
 | 
	
		
			
				|  |  |        }
 | 
	
	
		
			
				|  | @@ -2098,7 +2243,7 @@ void CallData::RecvInitialMetadataReady(void* arg, grpc_error* error) {
 | 
	
		
			
				|  |  |    grpc_call_element* elem = batch_data->elem;
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  |    CallData* calld = static_cast<CallData*>(elem->call_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: got recv_initial_metadata_ready, error=%s",
 | 
	
		
			
				|  |  |              chand, calld, grpc_error_string(error));
 | 
	
	
		
			
				|  | @@ -2122,7 +2267,7 @@ void CallData::RecvInitialMetadataReady(void* arg, grpc_error* error) {
 | 
	
		
			
				|  |  |    if (GPR_UNLIKELY((retry_state->trailing_metadata_available ||
 | 
	
		
			
				|  |  |                      error != GRPC_ERROR_NONE) &&
 | 
	
		
			
				|  |  |                     !retry_state->completed_recv_trailing_metadata)) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: deferring recv_initial_metadata_ready "
 | 
	
		
			
				|  |  |                "(Trailers-Only)",
 | 
	
	
		
			
				|  | @@ -2188,7 +2333,7 @@ void CallData::RecvMessageReady(void* arg, grpc_error* error) {
 | 
	
		
			
				|  |  |    grpc_call_element* elem = batch_data->elem;
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  |    CallData* calld = static_cast<CallData*>(elem->call_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: got recv_message_ready, error=%s",
 | 
	
		
			
				|  |  |              chand, calld, grpc_error_string(error));
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -2210,7 +2355,7 @@ void CallData::RecvMessageReady(void* arg, grpc_error* error) {
 | 
	
		
			
				|  |  |    if (GPR_UNLIKELY(
 | 
	
		
			
				|  |  |            (retry_state->recv_message == nullptr || error != GRPC_ERROR_NONE) &&
 | 
	
		
			
				|  |  |            !retry_state->completed_recv_trailing_metadata)) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: deferring recv_message_ready (nullptr "
 | 
	
		
			
				|  |  |                "message and recv_trailing_metadata pending)",
 | 
	
	
		
			
				|  | @@ -2348,7 +2493,7 @@ void CallData::AddClosuresToFailUnstartedPendingBatches(
 | 
	
		
			
				|  |  |    for (size_t i = 0; i < GPR_ARRAY_SIZE(pending_batches_); ++i) {
 | 
	
		
			
				|  |  |      PendingBatch* pending = &pending_batches_[i];
 | 
	
		
			
				|  |  |      if (PendingBatchIsUnstarted(pending, retry_state)) {
 | 
	
		
			
				|  |  | -      if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +      if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |          gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                  "chand=%p calld=%p: failing unstarted pending batch at index "
 | 
	
		
			
				|  |  |                  "%" PRIuPTR,
 | 
	
	
		
			
				|  | @@ -2394,7 +2539,7 @@ void CallData::RecvTrailingMetadataReady(void* arg, grpc_error* error) {
 | 
	
		
			
				|  |  |    grpc_call_element* elem = batch_data->elem;
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  |    CallData* calld = static_cast<CallData*>(elem->call_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: got recv_trailing_metadata_ready, error=%s",
 | 
	
		
			
				|  |  |              chand, calld, grpc_error_string(error));
 | 
	
	
		
			
				|  | @@ -2410,7 +2555,7 @@ void CallData::RecvTrailingMetadataReady(void* arg, grpc_error* error) {
 | 
	
		
			
				|  |  |        batch_data->batch.payload->recv_trailing_metadata.recv_trailing_metadata;
 | 
	
		
			
				|  |  |    calld->GetCallStatus(elem, md_batch, GRPC_ERROR_REF(error), &status,
 | 
	
		
			
				|  |  |                         &server_pushback_md);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: call finished, status=%s", chand,
 | 
	
		
			
				|  |  |              calld, grpc_status_code_to_string(status));
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -2489,7 +2634,7 @@ void CallData::AddClosuresForReplayOrPendingSendOps(
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |    if (have_pending_send_message_ops || have_pending_send_trailing_metadata_op) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: starting next batch for pending send op(s)",
 | 
	
		
			
				|  |  |                chand, this);
 | 
	
	
		
			
				|  | @@ -2508,7 +2653,7 @@ void CallData::OnComplete(void* arg, grpc_error* error) {
 | 
	
		
			
				|  |  |    grpc_call_element* elem = batch_data->elem;
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  |    CallData* calld = static_cast<CallData*>(elem->call_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      char* batch_str = grpc_transport_stream_op_batch_string(&batch_data->batch);
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: got on_complete, error=%s, batch=%s",
 | 
	
		
			
				|  |  |              chand, calld, grpc_error_string(error), batch_str);
 | 
	
	
		
			
				|  | @@ -2584,7 +2729,7 @@ void CallData::AddClosureForSubchannelBatch(
 | 
	
		
			
				|  |  |    batch->handler_private.extra_arg = subchannel_call_.get();
 | 
	
		
			
				|  |  |    GRPC_CLOSURE_INIT(&batch->handler_private.closure, StartBatchInCallCombiner,
 | 
	
		
			
				|  |  |                      batch, grpc_schedule_on_exec_ctx);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      char* batch_str = grpc_transport_stream_op_batch_string(batch);
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: starting subchannel batch: %s", chand,
 | 
	
		
			
				|  |  |              this, batch_str);
 | 
	
	
		
			
				|  | @@ -2647,7 +2792,7 @@ void CallData::AddRetriableSendMessageOp(grpc_call_element* elem,
 | 
	
		
			
				|  |  |                                           SubchannelCallRetryState* retry_state,
 | 
	
		
			
				|  |  |                                           SubchannelCallBatchData* batch_data) {
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: starting calld->send_messages[%" PRIuPTR "]",
 | 
	
		
			
				|  |  |              chand, this, retry_state->started_send_message_count);
 | 
	
	
		
			
				|  | @@ -2730,7 +2875,7 @@ void CallData::AddRetriableRecvTrailingMetadataOp(
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void CallData::StartInternalRecvTrailingMetadata(grpc_call_element* elem) {
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: call failed but recv_trailing_metadata not "
 | 
	
		
			
				|  |  |              "started; starting it internally",
 | 
	
	
		
			
				|  | @@ -2762,7 +2907,7 @@ CallData::MaybeCreateSubchannelBatchForReplay(
 | 
	
		
			
				|  |  |    if (seen_send_initial_metadata_ &&
 | 
	
		
			
				|  |  |        !retry_state->started_send_initial_metadata &&
 | 
	
		
			
				|  |  |        !pending_send_initial_metadata_) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: replaying previously completed "
 | 
	
		
			
				|  |  |                "send_initial_metadata op",
 | 
	
	
		
			
				|  | @@ -2778,7 +2923,7 @@ CallData::MaybeCreateSubchannelBatchForReplay(
 | 
	
		
			
				|  |  |        retry_state->started_send_message_count ==
 | 
	
		
			
				|  |  |            retry_state->completed_send_message_count &&
 | 
	
		
			
				|  |  |        !pending_send_message_) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: replaying previously completed "
 | 
	
		
			
				|  |  |                "send_message op",
 | 
	
	
		
			
				|  | @@ -2798,7 +2943,7 @@ CallData::MaybeCreateSubchannelBatchForReplay(
 | 
	
		
			
				|  |  |        retry_state->started_send_message_count == send_messages_.size() &&
 | 
	
		
			
				|  |  |        !retry_state->started_send_trailing_metadata &&
 | 
	
		
			
				|  |  |        !pending_send_trailing_metadata_) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: replaying previously completed "
 | 
	
		
			
				|  |  |                "send_trailing_metadata op",
 | 
	
	
		
			
				|  | @@ -2883,6 +3028,8 @@ void CallData::AddSubchannelBatchesForPendingBatches(
 | 
	
		
			
				|  |  |      // If we're not retrying, just send the batch as-is.
 | 
	
		
			
				|  |  |      if (method_params_ == nullptr ||
 | 
	
		
			
				|  |  |          method_params_->retry_policy() == nullptr || retry_committed_) {
 | 
	
		
			
				|  |  | +      // TODO(roth) : We should probably call
 | 
	
		
			
				|  |  | +      // MaybeInjectRecvTrailingMetadataReadyForLoadBalancingPolicy here.
 | 
	
		
			
				|  |  |        AddClosureForSubchannelBatch(elem, batch, closures);
 | 
	
		
			
				|  |  |        PendingBatchClear(pending);
 | 
	
		
			
				|  |  |        continue;
 | 
	
	
		
			
				|  | @@ -2941,7 +3088,7 @@ void CallData::StartRetriableSubchannelBatches(void* arg, grpc_error* ignored) {
 | 
	
		
			
				|  |  |    grpc_call_element* elem = static_cast<grpc_call_element*>(arg);
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  |    CallData* calld = static_cast<CallData*>(elem->call_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: constructing retriable batches",
 | 
	
		
			
				|  |  |              chand, calld);
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -2966,7 +3113,7 @@ void CallData::StartRetriableSubchannelBatches(void* arg, grpc_error* ignored) {
 | 
	
		
			
				|  |  |    // Now add pending batches.
 | 
	
		
			
				|  |  |    calld->AddSubchannelBatchesForPendingBatches(elem, retry_state, &closures);
 | 
	
		
			
				|  |  |    // Start batches on subchannel call.
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_call_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_call_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: starting %" PRIuPTR
 | 
	
		
			
				|  |  |              " retriable batches on subchannel_call=%p",
 | 
	
	
		
			
				|  | @@ -2992,7 +3139,7 @@ void CallData::CreateSubchannelCall(grpc_call_element* elem) {
 | 
	
		
			
				|  |  |    grpc_error* error = GRPC_ERROR_NONE;
 | 
	
		
			
				|  |  |    subchannel_call_ =
 | 
	
		
			
				|  |  |        pick_.pick.connected_subchannel->CreateCall(call_args, &error);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: create subchannel_call=%p: error=%s",
 | 
	
		
			
				|  |  |              chand, this, subchannel_call_.get(), grpc_error_string(error));
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -3012,7 +3159,7 @@ void CallData::PickDone(void* arg, grpc_error* error) {
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  |    CallData* calld = static_cast<CallData*>(elem->call_data);
 | 
	
		
			
				|  |  |    if (error != GRPC_ERROR_NONE) {
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: failed to pick subchannel: error=%s", chand,
 | 
	
		
			
				|  |  |                calld, grpc_error_string(error));
 | 
	
	
		
			
				|  | @@ -3041,7 +3188,7 @@ class CallData::QueuedPickCanceller {
 | 
	
		
			
				|  |  |      auto* self = static_cast<QueuedPickCanceller*>(arg);
 | 
	
		
			
				|  |  |      auto* chand = static_cast<ChannelData*>(self->elem_->channel_data);
 | 
	
		
			
				|  |  |      auto* calld = static_cast<CallData*>(self->elem_->call_data);
 | 
	
		
			
				|  |  | -    if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | +    if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |                "chand=%p calld=%p: cancelling queued pick: "
 | 
	
		
			
				|  |  |                "error=%s self=%p calld->pick_canceller=%p",
 | 
	
	
		
			
				|  | @@ -3065,7 +3212,7 @@ class CallData::QueuedPickCanceller {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void CallData::RemoveCallFromQueuedPicksLocked(grpc_call_element* elem) {
 | 
	
		
			
				|  |  |    auto* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: removing from queued picks list",
 | 
	
		
			
				|  |  |              chand, this);
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -3077,7 +3224,7 @@ void CallData::RemoveCallFromQueuedPicksLocked(grpc_call_element* elem) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void CallData::AddCallToQueuedPicksLocked(grpc_call_element* elem) {
 | 
	
		
			
				|  |  |    auto* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: adding to queued picks list", chand,
 | 
	
		
			
				|  |  |              this);
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -3090,7 +3237,7 @@ void CallData::AddCallToQueuedPicksLocked(grpc_call_element* elem) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  void CallData::ApplyServiceConfigToCallLocked(grpc_call_element* elem) {
 | 
	
		
			
				|  |  |    ChannelData* chand = static_cast<ChannelData*>(elem->channel_data);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "chand=%p calld=%p: applying service config to call",
 | 
	
		
			
				|  |  |              chand, this);
 | 
	
		
			
				|  |  |    }
 | 
	
	
		
			
				|  | @@ -3199,7 +3346,7 @@ void CallData::StartPickLocked(void* arg, grpc_error* error) {
 | 
	
		
			
				|  |  |    // Attempt pick.
 | 
	
		
			
				|  |  |    error = GRPC_ERROR_NONE;
 | 
	
		
			
				|  |  |    auto pick_result = chand->picker()->Pick(&calld->pick_.pick, &error);
 | 
	
		
			
				|  |  | -  if (grpc_client_channel_routing_trace.enabled()) {
 | 
	
		
			
				|  |  | +  if (GRPC_TRACE_FLAG_ENABLED(grpc_client_channel_routing_trace)) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO,
 | 
	
		
			
				|  |  |              "chand=%p calld=%p: LB pick returned %s (connected_subchannel=%p, "
 | 
	
		
			
				|  |  |              "error=%s)",
 |