@@ -35,7 +35,7 @@ const (
3535// TransportConfig extends configgrpc.ClientConfig with additional HTTP-specific settings
3636type TransportConfig struct {
3737 // Embed the gRPC configuration to ensure backward compatibility
38- configgrpc.ClientConfig `mapstructure:",squash"`
38+ ClientConfig configgrpc.ClientConfig `mapstructure:",squash"`
3939
4040 // The following fields are only used when protocol is "http"
4141 ProxyURL string `mapstructure:"proxy_url,omitempty"` // Used only if protocol is http
@@ -47,20 +47,20 @@ type TransportConfig struct {
4747}
4848
4949func (c * TransportConfig ) ToHTTPClient (ctx context.Context , host component.Host , settings component.TelemetrySettings ) (* http.Client , error ) {
50- c .Headers .Set ("Content-Type" , "application/x-protobuf" )
50+ c .ClientConfig . Headers .Set ("Content-Type" , "application/x-protobuf" )
5151
5252 httpClientConfig := confighttp .NewDefaultClientConfig ()
5353 // TODO: See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/49316.
5454 httpClientConfig .MaxIdleConns = 0
5555 httpClientConfig .IdleConnTimeout = 0
5656 httpClientConfig .ForceAttemptHTTP2 = false
5757 httpClientConfig .ProxyURL = c .ProxyURL
58- httpClientConfig .TLS = c .TLS
59- httpClientConfig .ReadBufferSize = c .ReadBufferSize
60- httpClientConfig .WriteBufferSize = c .WriteBufferSize
58+ httpClientConfig .TLS = c .ClientConfig . TLS
59+ httpClientConfig .ReadBufferSize = c .ClientConfig . ReadBufferSize
60+ httpClientConfig .WriteBufferSize = c .ClientConfig . WriteBufferSize
6161 httpClientConfig .Timeout = c .Timeout
62- httpClientConfig .Headers = c .Headers
63- httpClientConfig .Compression = c .Compression
62+ httpClientConfig .Headers = c .ClientConfig . Headers
63+ httpClientConfig .Compression = c .ClientConfig . Compression
6464 return httpClientConfig .ToClient (ctx , host .GetExtensions (), settings )
6565}
6666
@@ -138,43 +138,43 @@ func (c *Config) Unmarshal(conf *confmap.Conf) error {
138138 _ = setDomainGrpcSettings (c )
139139 var err error
140140
141- if ! isEmpty (c .Domain ) && isEmpty (c .Metrics .Endpoint ) {
141+ if ! isEmpty (c .Domain ) && isEmpty (c .Metrics .ClientConfig . Endpoint ) {
142142 c .Metrics , err = setMergedTransportConfigWithConf (conf , c , "metrics" , & c .Metrics )
143143 if err != nil {
144144 return err
145145 }
146146 }
147147
148- if isEmpty (c .Metrics .Endpoint ) {
149- c .Metrics .Endpoint = ensureHTTPScheme (c .DomainSettings .Endpoint )
148+ if isEmpty (c .Metrics .ClientConfig . Endpoint ) {
149+ c .Metrics .ClientConfig . Endpoint = ensureHTTPScheme (c .DomainSettings . ClientConfig .Endpoint )
150150 } else if c .Protocol == httpProtocol {
151- c .Metrics .Endpoint = ensureHTTPScheme (c .Metrics .Endpoint )
151+ c .Metrics .ClientConfig . Endpoint = ensureHTTPScheme (c .Metrics . ClientConfig .Endpoint )
152152 }
153153
154- if ! isEmpty (c .Domain ) && isEmpty (c .Traces .Endpoint ) {
154+ if ! isEmpty (c .Domain ) && isEmpty (c .Traces .ClientConfig . Endpoint ) {
155155 c .Traces , err = setMergedTransportConfigWithConf (conf , c , "traces" , & c .Traces )
156156 if err != nil {
157157 return err
158158 }
159159 }
160160
161- if isEmpty (c .Traces .Endpoint ) {
162- c .Traces .Endpoint = ensureHTTPScheme (c .DomainSettings .Endpoint )
161+ if isEmpty (c .Traces .ClientConfig . Endpoint ) {
162+ c .Traces .ClientConfig . Endpoint = ensureHTTPScheme (c .DomainSettings . ClientConfig .Endpoint )
163163 } else if c .Protocol == httpProtocol {
164- c .Traces .Endpoint = ensureHTTPScheme (c .Traces .Endpoint )
164+ c .Traces .ClientConfig . Endpoint = ensureHTTPScheme (c .Traces . ClientConfig .Endpoint )
165165 }
166166
167- if ! isEmpty (c .Domain ) && isEmpty (c .Logs .Endpoint ) {
167+ if ! isEmpty (c .Domain ) && isEmpty (c .Logs .ClientConfig . Endpoint ) {
168168 c .Logs , err = setMergedTransportConfigWithConf (conf , c , "logs" , & c .Logs )
169169 if err != nil {
170170 return err
171171 }
172172 }
173173
174- if isEmpty (c .Logs .Endpoint ) {
175- c .Logs .Endpoint = ensureHTTPScheme (c .DomainSettings .Endpoint )
174+ if isEmpty (c .Logs .ClientConfig . Endpoint ) {
175+ c .Logs .ClientConfig . Endpoint = ensureHTTPScheme (c .DomainSettings . ClientConfig .Endpoint )
176176 } else if c .Protocol == httpProtocol {
177- c .Logs .Endpoint = ensureHTTPScheme (c .Logs .Endpoint )
177+ c .Logs .ClientConfig . Endpoint = ensureHTTPScheme (c .Logs . ClientConfig .Endpoint )
178178 }
179179
180180 // Only auto-populate profiles endpoint if protocol is not HTTP (profiles only support gRPC)
@@ -188,8 +188,8 @@ func (c *Config) Unmarshal(conf *confmap.Conf) error {
188188
189189 // Only set profiles endpoint fallback if protocol is not HTTP and we have something to fallback to
190190 // This avoid validation issues
191- if c .Protocol != httpProtocol && isEmpty (c .Profiles .Endpoint ) && ! isEmpty (c .DomainSettings .Endpoint ) {
192- c .Profiles .Endpoint = ensureHTTPScheme (c .DomainSettings .Endpoint )
191+ if c .Protocol != httpProtocol && isEmpty (c .Profiles .Endpoint ) && ! isEmpty (c .DomainSettings .ClientConfig . Endpoint ) {
192+ c .Profiles .Endpoint = ensureHTTPScheme (c .DomainSettings .ClientConfig . Endpoint )
193193 }
194194 return nil
195195}
@@ -214,9 +214,9 @@ func (c *Config) Validate() error {
214214
215215 // validate that at least one endpoint is set up correctly
216216 if isEmpty (c .Domain ) &&
217- isEmpty (c .Traces .Endpoint ) &&
218- isEmpty (c .Metrics .Endpoint ) &&
219- isEmpty (c .Logs .Endpoint ) &&
217+ isEmpty (c .Traces .ClientConfig . Endpoint ) &&
218+ isEmpty (c .Metrics .ClientConfig . Endpoint ) &&
219+ isEmpty (c .Logs .ClientConfig . Endpoint ) &&
220220 isEmpty (c .Profiles .Endpoint ) {
221221 return errors .New ("`domain` or `traces.endpoint` or `metrics.endpoint` or `logs.endpoint` or `profiles.endpoint` not specified, please fix the configuration" )
222222 }
@@ -376,51 +376,51 @@ func setMergedTransportConfig(c *Config, merged *TransportConfig, signalSub *con
376376 }
377377
378378 if signalSub != nil && signalSub .IsSet ("compression" ) {
379- merged .Compression = signalConfig .Compression
379+ merged .ClientConfig . Compression = signalConfig . ClientConfig .Compression
380380 }
381381 if signalSub != nil && signalSub .IsSet ("accept_encoding" ) {
382382 merged .AcceptEncoding = signalConfig .AcceptEncoding
383383 }
384- if signalConfig .TLS .Insecure || signalConfig .TLS .InsecureSkipVerify || signalConfig .TLS .CAFile != "" {
385- merged .TLS = signalConfig .TLS
384+ if signalConfig .ClientConfig . TLS .Insecure || signalConfig .ClientConfig . TLS .InsecureSkipVerify || signalConfig . ClientConfig .TLS .CAFile != "" {
385+ merged .ClientConfig . TLS = signalConfig . ClientConfig .TLS
386386 }
387- if len (signalConfig .Headers ) > 0 {
387+ if len (signalConfig .ClientConfig . Headers ) > 0 {
388388 // MapList.Set copies the backing array, so this does not mutate c.DomainSettings
389- for k , v := range signalConfig .Headers .Iter {
390- merged .Headers .Set (k , v )
389+ for k , v := range signalConfig .ClientConfig . Headers .Iter {
390+ merged .ClientConfig . Headers .Set (k , v )
391391 }
392392 }
393- if signalConfig .WriteBufferSize > 0 {
394- merged .WriteBufferSize = signalConfig .WriteBufferSize
393+ if signalConfig .ClientConfig . WriteBufferSize > 0 {
394+ merged .ClientConfig . WriteBufferSize = signalConfig . ClientConfig .WriteBufferSize
395395 }
396- if signalConfig .ReadBufferSize > 0 {
397- merged .ReadBufferSize = signalConfig .ReadBufferSize
396+ if signalConfig .ClientConfig . ReadBufferSize > 0 {
397+ merged .ClientConfig . ReadBufferSize = signalConfig . ClientConfig .ReadBufferSize
398398 }
399- if signalConfig .WaitForReady {
400- merged .WaitForReady = signalConfig .WaitForReady
399+ if signalConfig .ClientConfig . WaitForReady {
400+ merged .ClientConfig . WaitForReady = signalConfig . ClientConfig .WaitForReady
401401 }
402- if signalConfig .BalancerName != "" {
403- merged .BalancerName = signalConfig .BalancerName
402+ if signalConfig .ClientConfig . BalancerName != "" {
403+ merged .ClientConfig . BalancerName = signalConfig . ClientConfig .BalancerName
404404 }
405- if signalConfig .Keepalive .HasValue () {
406- merged .Keepalive = signalConfig .Keepalive
405+ if signalConfig .ClientConfig . Keepalive .HasValue () {
406+ merged .ClientConfig . Keepalive = signalConfig . ClientConfig .Keepalive
407407 }
408- if signalConfig .Auth .HasValue () {
409- merged .Auth = signalConfig .Auth
408+ if signalConfig .ClientConfig . Auth .HasValue () {
409+ merged .ClientConfig . Auth = signalConfig . ClientConfig .Auth
410410 }
411411
412- if isEmpty (signalConfig .Endpoint ) {
413- merged .Endpoint = setDomainGrpcSettings (c )
412+ if isEmpty (signalConfig .ClientConfig . Endpoint ) {
413+ merged .ClientConfig . Endpoint = setDomainGrpcSettings (c )
414414 } else {
415- merged .Endpoint = signalConfig .Endpoint
415+ merged .ClientConfig . Endpoint = signalConfig . ClientConfig .Endpoint
416416 }
417417
418418 return merged
419419}
420420
421421func applyTransportDefaults (cfg * TransportConfig ) {
422- if cfg .Compression == "" {
423- cfg .Compression = configcompression .TypeGzip
422+ if cfg .ClientConfig . Compression == "" {
423+ cfg .ClientConfig . Compression = configcompression .TypeGzip
424424 }
425425 if cfg .AcceptEncoding == "" {
426426 cfg .AcceptEncoding = gzip .Name
0 commit comments