func commonConfigWithHTTPPath()

in cmd/apmbench/bench_otlp.go [22:69]


func commonConfigWithHTTPPath(httpPath string) common.Config {
	insecure := !loadgencfg.Config.Secure

	serverURL := loadgencfg.Config.ServerURL
	endpoint := serverURL.Host
	if serverURL.Port() == "" {
		switch serverURL.Scheme {
		case "http":
			endpoint += ":80"
			insecure = true
		case "https":
			endpoint += ":443"
		}
	}

	secretToken := loadgencfg.Config.SecretToken
	apiKey := loadgencfg.Config.APIKey
	headers := make(map[string]string)
	for k, v := range loadgencfg.Config.Headers {
		headers[k] = v
	}
	if secretToken != "" || apiKey != "" {
		if apiKey != "" {
			// higher priority to APIKey auth
			headers["Authorization"] = "ApiKey " + apiKey
		} else {
			headers["Authorization"] = "Bearer " + secretToken
		}
	}

	return common.Config{
		WorkerCount:           runtime.GOMAXPROCS(0),
		Rate:                  0,
		TotalDuration:         0,
		ReportingInterval:     0,
		SkipSettingGRPCLogger: true,
		CustomEndpoint:        endpoint,
		Insecure:              insecure,
		UseHTTP:               false,
		HTTPPath:              httpPath,
		Headers:               headers,
		ResourceAttributes:    nil,
		TelemetryAttributes:   nil,
		CaFile:                "",
		ClientAuth:            common.ClientAuth{},
		Logger:                zap.NewNop(),
	}
}