func FromAgentConfig(agentConfig Config, converter *config.LegacyConfigConverter) error {
	if err := extractURLAPIKeys(agentConfig, converter); err != nil {
		return err
	}

	if proxy, err := BuildProxySettings(agentConfig); err == nil {
		if u, ok := proxy["http"]; ok {
			converter.Set("proxy.http", u)
		}
		if u, ok := proxy["https"]; ok {
			converter.Set("proxy.https", u)
		}
	}

	if enabled, err := isAffirmative(agentConfig["skip_ssl_validation"]); err == nil {
		converter.Set("skip_ssl_validation", enabled)
	}

	converter.Set("hostname", agentConfig["hostname"])

	if enabled, err := isAffirmative(agentConfig["process_agent_enabled"]); enabled {
		// process agent is explicitly enabled
		converter.Set("process_config.enabled", "true")
	} else if err == nil && !enabled {
		// process agent is explicitly disabled
		converter.Set("process_config.enabled", "disabled")
	}

	tags := strings.Split(agentConfig["tags"], ",")
	for i, tag := range tags {
		tags[i] = strings.TrimSpace(tag)
	}
	converter.Set("tags", tags)

	if value, err := strconv.Atoi(agentConfig["forwarder_timeout"]); err == nil {
		converter.Set("forwarder_timeout", value)
	}

	if value, err := strconv.Atoi(agentConfig["default_integration_http_timeout"]); err == nil {
		converter.Set("default_integration_http_timeout", value)
	}

	if enabled, err := isAffirmative(agentConfig["collect_ec2_tags"]); err == nil {
		converter.Set("collect_ec2_tags", enabled)
	}

	// config.Datadog has a default value for this, do nothing if the value is empty
	if agentConfig["additional_checksd"] != "" {
		converter.Set("additional_checksd", agentConfig["additional_checksd"])
	}

	// TODO: exclude_process_args

	histogramAggregates := buildHistogramAggregates(agentConfig)
	if histogramAggregates != nil && len(histogramAggregates) != 0 {
		converter.Set("histogram_aggregates", histogramAggregates)
	}

	histogramPercentiles := buildHistogramPercentiles(agentConfig)
	if histogramPercentiles != nil && len(histogramPercentiles) != 0 {
		converter.Set("histogram_percentiles", histogramPercentiles)
	}

	if agentConfig["service_discovery_backend"] == "docker" {
		// `docker` is the only possible value also on the Agent v5
		dockerListener := config.Listeners{Name: "docker"}
		converter.Set("listeners", []config.Listeners{dockerListener})
	}

	if providers, err := buildConfigProviders(agentConfig); err == nil {
		converter.Set("config_providers", providers)
	}

	// config.Datadog has a default value for this, do nothing if the value is empty
	if agentConfig["sd_template_dir"] != "" {
		converter.Set("autoconf_template_dir", agentConfig["sd_template_dir"])
	}

	if enabled, err := isAffirmative(agentConfig["use_dogstatsd"]); err == nil {
		converter.Set("use_dogstatsd", enabled)
	}

	if value, err := strconv.Atoi(agentConfig["dogstatsd_port"]); err == nil {
		converter.Set("dogstatsd_port", value)
	}

	converter.Set("statsd_metric_namespace", agentConfig["statsd_metric_namespace"])

	// config.Datadog has a default value for this, do nothing if the value is empty
	if agentConfig["log_level"] != "" {
		converter.Set("log_level", agentConfig["log_level"])
	}

	// config.Datadog has a default value for this, do nothing if the value is empty
	if agentConfig["collector_log_file"] != "" {
		converter.Set("log_file", agentConfig["collector_log_file"])
	}

	// config.Datadog has a default value for this, do nothing if the value is empty
	if agentConfig["disable_file_logging"] != "" {
		converter.Set("disable_file_logging", agentConfig["disable_file_logging"])
	}

	if enabled, err := isAffirmative(agentConfig["log_to_syslog"]); err == nil {
		converter.Set("log_to_syslog", enabled)
	}
	converter.Set("syslog_uri", buildSyslogURI(agentConfig))

	if enabled, err := isAffirmative(agentConfig["collect_instance_metadata"]); err == nil {
		converter.Set("enable_metadata_collection", enabled)
	}

	if enabled, err := isAffirmative(agentConfig["enable_gohai"]); err == nil {
		converter.Set("enable_gohai", enabled)
	}

	if agentConfig["bind_host"] != "" {
		converter.Set("bind_host", agentConfig["bind_host"])
	}

	//Trace APM based configurations

	if agentConfig["apm_enabled"] != "" {
		if enabled, err := isAffirmative(agentConfig["apm_enabled"]); err == nil {
			converter.Set("apm_config.enabled", enabled)
		}
	}

	if agentConfig["non_local_traffic"] != "" {
		if enabled, err := isAffirmative(agentConfig["non_local_traffic"]); err == nil {
			converter.Set("dogstatsd_non_local_traffic", enabled)
			// trace-agent listen locally by default, convert the config only if configured to listen to more
			converter.Set("apm_config.apm_non_local_traffic", enabled)
		}
	}

	converter.Set("hostname_fqdn", true)

	return extractTraceAgentConfig(agentConfig, converter)
}
// FromAgentConfig reads the old agentConfig configuration, converts and merges
// the values into the current configuration object
FromAgentConfig reads the old agentConfig configuration, converts and merges
the values into the current configuration object
// FromAgentConfig reads the old agentConfig configuration converts and merges // the values into the current configuration object
func FromAgentConfig(agentConfig Config, converter *config.LegacyConfigConverter) error {
	if err := extractURLAPIKeys(agentConfig, converter); err != nil {
		return err
	}
	if proxy, err := BuildProxySettings(agentConfig); err == nil {
		if u, ok := proxy["http"]; ok {
			converter.Set("proxy.http", u)
		}
		if u, ok := proxy["https"]; ok {
			converter.Set("proxy.https", u)
		}
	}
	if enabled, err := isAffirmative(agentConfig["skip_ssl_validation"]); err == nil {
		converter.Set("skip_ssl_validation", enabled)
	}
	converter.Set("hostname", agentConfig["hostname"])
	if enabled, err := isAffirmative(agentConfig["process_agent_enabled"]); enabled {
		converter.Set("process_config.enabled", "true")
	} else if err == nil && !enabled {
		converter.Set("process_config.enabled", "disabled")
	}
	tags := strings.Split(agentConfig["tags"], ",")
	for i, tag := range tags {
		tags[i] = strings.TrimSpace(tag)
	}
	converter.Set("tags", tags)
	if value, err := strconv.Atoi(agentConfig["forwarder_timeout"]); err == nil {
		converter.Set("forwarder_timeout", value)
	}
	if value, err := strconv.Atoi(agentConfig["default_integration_http_timeout"]); err == nil {
		converter.Set("default_integration_http_timeout", value)
	}
	if enabled, err := isAffirmative(agentConfig["collect_ec2_tags"]); err == nil {
		converter.Set("collect_ec2_tags", enabled)
	}
	if agentConfig["additional_checksd"] != "" {
		converter.Set("additional_checksd", agentConfig["additional_checksd"])
	}
	histogramAggregates := buildHistogramAggregates(agentConfig)
	if histogramAggregates != nil && len(histogramAggregates) != 0 {
		converter.Set("histogram_aggregates", histogramAggregates)
	}
	histogramPercentiles := buildHistogramPercentiles(agentConfig)
	if histogramPercentiles != nil && len(histogramPercentiles) != 0 {
		converter.Set("histogram_percentiles", histogramPercentiles)
	}
	if agentConfig["service_discovery_backend"] == "docker" {
		dockerListener := config.Listeners{Name: "docker"}
		converter.Set("listeners", []config.Listeners{dockerListener})
	}
	if providers, err := buildConfigProviders(agentConfig); err == nil {
		converter.Set("config_providers", providers)
	}
	if agentConfig["sd_template_dir"] != "" {
		converter.Set("autoconf_template_dir", agentConfig["sd_template_dir"])
	}
	if enabled, err := isAffirmative(agentConfig["use_dogstatsd"]); err == nil {
		converter.Set("use_dogstatsd", enabled)
	}
	if value, err := strconv.Atoi(agentConfig["dogstatsd_port"]); err == nil {
		converter.Set("dogstatsd_port", value)
	}
	converter.Set("statsd_metric_namespace", agentConfig["statsd_metric_namespace"])
	if agentConfig["log_level"] != "" {
		converter.Set("log_level", agentConfig["log_level"])
	}
	if agentConfig["collector_log_file"] != "" {
		converter.Set("log_file", agentConfig["collector_log_file"])
	}
	if agentConfig["disable_file_logging"] != "" {
		converter.Set("disable_file_logging", agentConfig["disable_file_logging"])
	}
	if enabled, err := isAffirmative(agentConfig["log_to_syslog"]); err == nil {
		converter.Set("log_to_syslog", enabled)
	}
	converter.Set("syslog_uri", buildSyslogURI(agentConfig))
	if enabled, err := isAffirmative(agentConfig["collect_instance_metadata"]); err == nil {
		converter.Set("enable_metadata_collection", enabled)
	}
	if enabled, err := isAffirmative(agentConfig["enable_gohai"]); err == nil {
		converter.Set("enable_gohai", enabled)
	}
	if agentConfig["bind_host"] != "" {
		converter.Set("bind_host", agentConfig["bind_host"])
	}
	if agentConfig["apm_enabled"] != "" {
		if enabled, err := isAffirmative(agentConfig["apm_enabled"]); err == nil {
			converter.Set("apm_config.enabled", enabled)
		}
	}
	if agentConfig["non_local_traffic"] != "" {
		if enabled, err := isAffirmative(agentConfig["non_local_traffic"]); err == nil {
			converter.Set("dogstatsd_non_local_traffic", enabled)
			converter.Set("apm_config.apm_non_local_traffic", enabled)
		}
	}
	converter.Set("hostname_fqdn", true)
	return extractTraceAgentConfig(agentConfig, converter)
}
func FromAgentConfig ( agentConfig Config , converter * config . LegacyConfigConverter ) error { if err := extractURLAPIKeys ( agentConfig , converter ) ; err != nil { return err } if proxy , err := BuildProxySettings ( agentConfig ) ; err == nil { if u , ok := proxy [ " " ] ; ok { converter . Set ( " " , u ) } if u , ok := proxy [ " " ] ; ok { converter . Set ( " " , u ) } } if enabled , err := isAffirmative ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , enabled ) } converter . Set ( " " , agentConfig [ " " ] ) if enabled , err := isAffirmative ( agentConfig [ " " ] ) ; enabled { converter . Set ( " " , " " ) } else if err == nil && ! enabled { converter . Set ( " " , " " ) } tags := strings . Split ( agentConfig [ " " ] , " " ) for i , tag := range tags { tags [ i ] = strings . TrimSpace ( tag ) } converter . Set ( " " , tags ) if value , err := strconv . Atoi ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , value ) } if value , err := strconv . Atoi ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , value ) } if enabled , err := isAffirmative ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , enabled ) } if agentConfig [ " " ] != " " { converter . Set ( " " , agentConfig [ " " ] ) } histogramAggregates := buildHistogramAggregates ( agentConfig ) if histogramAggregates != nil && len ( histogramAggregates ) != 0 { converter . Set ( " " , histogramAggregates ) } histogramPercentiles := buildHistogramPercentiles ( agentConfig ) if histogramPercentiles != nil && len ( histogramPercentiles ) != 0 { converter . Set ( " " , histogramPercentiles ) } if agentConfig [ " " ] == " " { dockerListener := config . Listeners { Name : " " } converter . Set ( " " , [ ] config . Listeners { dockerListener } ) } if providers , err := buildConfigProviders ( agentConfig ) ; err == nil { converter . Set ( " " , providers ) } if agentConfig [ " " ] != " " { converter . Set ( " " , agentConfig [ " " ] ) } if enabled , err := isAffirmative ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , enabled ) } if value , err := strconv . Atoi ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , value ) } converter . Set ( " " , agentConfig [ " " ] ) if agentConfig [ " " ] != " " { converter . Set ( " " , agentConfig [ " " ] ) } if agentConfig [ " " ] != " " { converter . Set ( " " , agentConfig [ " " ] ) } if agentConfig [ " " ] != " " { converter . Set ( " " , agentConfig [ " " ] ) } if enabled , err := isAffirmative ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , enabled ) } converter . Set ( " " , buildSyslogURI ( agentConfig ) ) if enabled , err := isAffirmative ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , enabled ) } if enabled , err := isAffirmative ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , enabled ) } if agentConfig [ " " ] != " " { converter . Set ( " " , agentConfig [ " " ] ) } if agentConfig [ " " ] != " " { if enabled , err := isAffirmative ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , enabled ) } } if agentConfig [ " " ] != " " { if enabled , err := isAffirmative ( agentConfig [ " " ] ) ; err == nil { converter . Set ( " " , enabled ) converter . Set ( " " , enabled ) } } converter . Set ( " " , true ) return extractTraceAgentConfig ( agentConfig , converter ) }
FromAgentConfig reads the old agentConfig configuration, converts and merges
the values into the current configuration object
FromAgentConfig reads the old agentConfig configuration converts and merges the values into the current configuration object
// process agent is explicitly enabled // process agent is explicitly disabled // config.Datadog has a default value for this, do nothing if the value is empty // TODO: exclude_process_args // `docker` is the only possible value also on the Agent v5 // config.Datadog has a default value for this, do nothing if the value is empty // config.Datadog has a default value for this, do nothing if the value is empty // config.Datadog has a default value for this, do nothing if the value is empty // config.Datadog has a default value for this, do nothing if the value is empty //Trace APM based configurations // trace-agent listen locally by default, convert the config only if configured to listen to more