Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[chore] Update httpconfig API to not include HTTP prefix #9453

Merged
merged 1 commit into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ change_type: breaking
component: otlphttpexporter

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: otlphttpexporter.Config embeds the struct confighttp.HTTPClientConfig instead of confighttp.HTTPClientSettings
note: otlphttpexporter.Config embeds the struct confighttp.ClientConfig instead of confighttp.HTTPClientSettings

# One or more tracking issues or pull requests related to the change
issues: [6767]
Expand Down
2 changes: 1 addition & 1 deletion .chloggen/httpclientsettings_httpclientconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ change_type: deprecation
component: confighttp

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate HTTPClientSettings, use HTTPClientConfig instead
note: Deprecate HTTPClientSettings, use ClientConfig instead

# One or more tracking issues or pull requests related to the change
issues: [6767]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ change_type: breaking
component: otlpreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: HTTPConfig struct is moving from embedding the deprecated HTTPServerSettings struct to using HTTPServerConfig instead.
note: HTTPConfig struct is moving from embedding the deprecated ServerSettings struct to using HTTPServerConfig instead.

# One or more tracking issues or pull requests related to the change
issues: [6767]
Expand Down
2 changes: 1 addition & 1 deletion .chloggen/httpserversettings_httpserverconfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ change_type: deprecation
component: confighttp

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Deprecate HTTPServerSettings, use HTTPServerConfig instead
note: Deprecate HTTPServerSettings, use ServerConfig instead

# One or more tracking issues or pull requests related to the change
issues: [6767]
Expand Down
2 changes: 1 addition & 1 deletion config/confighttp/compression_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestHTTPClientCompression(t *testing.T) {
req, err := http.NewRequest(http.MethodGet, srv.URL, reqBody)
require.NoError(t, err, "failed to create request to test handler")

clientSettings := HTTPClientConfig{
clientSettings := ClientConfig{
Endpoint: srv.URL,
Compression: tt.encoding,
}
Expand Down
40 changes: 20 additions & 20 deletions config/confighttp/confighttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@
const headerContentEncoding = "Content-Encoding"

// HTTPClientSettings defines settings for creating an HTTP client.
// Deprecated: [v0.94.0] Use HTTPClientConfig instead
type HTTPClientSettings = HTTPClientConfig
// Deprecated: [v0.94.0] Use ClientConfig instead
type HTTPClientSettings = ClientConfig

// HTTPClientConfig defines settings for creating an HTTP client.
type HTTPClientConfig struct {
// ClientConfig defines settings for creating an HTTP client.
type ClientConfig struct {
// The target URL to send data to (e.g.: http://some.url:9411/v1/traces).
Endpoint string `mapstructure:"endpoint"`

Expand Down Expand Up @@ -107,28 +107,28 @@
// the default values of 'MaxIdleConns' and 'IdleConnTimeout'.
// Other config options are not added as they are initialized with 'zero value' by GoLang as default.
// We encourage to use this function to create an object of HTTPClientSettings.
// Deprecated: [v0.94.0] Use NewDefaultHTTPClientConfig instead
func NewDefaultHTTPClientSettings() HTTPClientConfig {
return NewDefaultHTTPClientConfig()
// Deprecated: [v0.94.0] Use NewDefaultClientConfig instead
func NewDefaultHTTPClientSettings() ClientConfig {
return NewDefaultClientConfig()

Check warning on line 112 in config/confighttp/confighttp.go

View check run for this annotation

Codecov / codecov/patch

config/confighttp/confighttp.go#L111-L112

Added lines #L111 - L112 were not covered by tests
}

// NewDefaultHTTPClientConfig returns HTTPClientConfig type object with
// NewDefaultClientConfig returns ClientConfig type object with
// the default values of 'MaxIdleConns' and 'IdleConnTimeout'.
// Other config options are not added as they are initialized with 'zero value' by GoLang as default.
// We encourage to use this function to create an object of HTTPClientConfig.
func NewDefaultHTTPClientConfig() HTTPClientConfig {
// We encourage to use this function to create an object of ClientConfig.
func NewDefaultClientConfig() ClientConfig {
// The default values are taken from the values of 'DefaultTransport' of 'http' package.
maxIdleConns := 100
idleConnTimeout := 90 * time.Second

return HTTPClientConfig{
return ClientConfig{
MaxIdleConns: &maxIdleConns,
IdleConnTimeout: &idleConnTimeout,
}
}

// ToClient creates an HTTP client.
func (hcs *HTTPClientConfig) ToClient(host component.Host, settings component.TelemetrySettings) (*http.Client, error) {
func (hcs *ClientConfig) ToClient(host component.Host, settings component.TelemetrySettings) (*http.Client, error) {
tlsCfg, err := hcs.TLSSetting.LoadTLSConfig()
if err != nil {
return nil, err
Expand Down Expand Up @@ -257,11 +257,11 @@
}

// HTTPServerSettings defines settings for creating an HTTP server.
// Deprecated: [v0.94.0] Use HTTPServerConfig instead
type HTTPServerSettings = HTTPServerConfig
// Deprecated: [v0.94.0] Use ServerConfig instead
type HTTPServerSettings = ServerConfig

// HTTPServerConfig defines settings for creating an HTTP server.
type HTTPServerConfig struct {
// ServerConfig defines settings for creating an HTTP server.
type ServerConfig struct {
// Endpoint configures the listening address for the server.
Endpoint string `mapstructure:"endpoint"`

Expand All @@ -287,7 +287,7 @@
}

// ToListener creates a net.Listener.
func (hss *HTTPServerConfig) ToListener() (net.Listener, error) {
func (hss *ServerConfig) ToListener() (net.Listener, error) {
listener, err := net.Listen("tcp", hss.Endpoint)
if err != nil {
return nil, err
Expand All @@ -306,14 +306,14 @@
}

// toServerOptions has options that change the behavior of the HTTP server
// returned by HTTPServerConfig.ToServer().
// returned by ServerConfig.ToServer().
type toServerOptions struct {
errHandler func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int)
decoders map[string]func(body io.ReadCloser) (io.ReadCloser, error)
}

// ToServerOption is an option to change the behavior of the HTTP server
// returned by HTTPServerConfig.ToServer().
// returned by ServerConfig.ToServer().
type ToServerOption func(opts *toServerOptions)

// WithErrorHandler overrides the HTTP error handler that gets invoked
Expand All @@ -336,7 +336,7 @@
}

// ToServer creates an http.Server from settings object.
func (hss *HTTPServerConfig) ToServer(host component.Host, settings component.TelemetrySettings, handler http.Handler, opts ...ToServerOption) (*http.Server, error) {
func (hss *ServerConfig) ToServer(host component.Host, settings component.TelemetrySettings, handler http.Handler, opts ...ToServerOption) (*http.Server, error) {
internal.WarnOnUnspecifiedHost(settings.Logger, hss.Endpoint)

serverOpts := &toServerOptions{}
Expand Down
Loading
Loading