diff --git a/config/confighttp/confighttp.go b/config/confighttp/confighttp.go index d2e71d2fd1f..14cecc23262 100644 --- a/config/confighttp/confighttp.go +++ b/config/confighttp/confighttp.go @@ -21,8 +21,6 @@ import ( "time" "github.com/rs/cors" - "go.uber.org/zap" - "go.opentelemetry.io/collector/config/configtls" "go.opentelemetry.io/collector/internal/middleware" ) @@ -144,18 +142,10 @@ func (hss *HTTPServerSettings) ToListener() (net.Listener, error) { // returned by HTTPServerSettings.ToServer(). type toServerOptions struct { errorHandler middleware.ErrorHandler - logger *zap.Logger } type ToServerOption func(opts *toServerOptions) -// WithLogger allows to specify optional logger used during initialization. -func WithLogger(logger *zap.Logger) ToServerOption { - return func(opts *toServerOptions) { - opts.logger = logger - } -} - // WithErrorHandler overrides the HTTP error handler that gets invoked // when there is a failure inside middleware.HTTPContentDecompressor. func WithErrorHandler(e middleware.ErrorHandler) ToServerOption { @@ -172,10 +162,8 @@ func (hss *HTTPServerSettings) ToServer(handler http.Handler, opts ...ToServerOp if len(hss.CorsOrigins) > 0 { co := cors.Options{AllowedOrigins: hss.CorsOrigins, AllowedHeaders: hss.CorsHeaders} handler = cors.New(co).Handler(handler) - } else if len(hss.CorsHeaders) > 0 && serverOpts.logger != nil { - serverOpts.logger.Warn( - "CORS needs to be enabled via `cors_allowed_origins` for `cors_allowed_headers` to have an effect") } + // TODO: emit a warning when non-empty CorsHeaders and empty CorsOrigins. handler = middleware.HTTPContentDecompressor( handler, diff --git a/config/confighttp/confighttp_test.go b/config/confighttp/confighttp_test.go index 652ffcc8bbd..a78b05dbc63 100644 --- a/config/confighttp/confighttp_test.go +++ b/config/confighttp/confighttp_test.go @@ -27,8 +27,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "go.uber.org/zap" - "go.opentelemetry.io/collector/config/configtls" ) @@ -391,7 +389,7 @@ func TestHttpCorsInvalidSettings(t *testing.T) { } // This effectively does not enable CORS but should also not cause an error - s := hss.ToServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}), WithLogger(zap.NewNop())) + s := hss.ToServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) require.NotNil(t, s) require.NoError(t, s.Close()) } diff --git a/receiver/otlpreceiver/otlp.go b/receiver/otlpreceiver/otlp.go index c00a38601a7..875ea52b350 100644 --- a/receiver/otlpreceiver/otlp.go +++ b/receiver/otlpreceiver/otlp.go @@ -143,7 +143,6 @@ func (r *otlpReceiver) startProtocolServers(host component.Host) error { r.serverHTTP = r.cfg.HTTP.ToServer( r.gatewayMux, confighttp.WithErrorHandler(errorHandler), - confighttp.WithLogger(r.logger), ) err = r.startHTTPServer(r.cfg.HTTP, host) if err != nil {