diff --git a/config/confighttp/Makefile b/config/confighttp/Makefile deleted file mode 100644 index ded7a36092dc..000000000000 --- a/config/confighttp/Makefile +++ /dev/null @@ -1 +0,0 @@ -include ../../Makefile.Common diff --git a/config/confighttp/README.md b/config/confighttp/README.md deleted file mode 100644 index 9d297cb1ab5d..000000000000 --- a/config/confighttp/README.md +++ /dev/null @@ -1,107 +0,0 @@ -# HTTP Configuration Settings - -HTTP exposes a [variety of settings](https://golang.org/pkg/net/http/). -Several of these settings are available for configuration within individual -receivers or exporters. - -## Client Configuration - -[Exporters](https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/README.md) -leverage client configuration. - -Note that client configuration supports TLS configuration, the -configuration parameters are also defined under `tls` like server -configuration. For more information, see [configtls -README](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md). - -- `endpoint`: address:port -- [`tls`](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md) -- `headers`: name/value pairs added to the HTTP request headers -- [`read_buffer_size`](https://golang.org/pkg/net/http/#Transport) -- [`timeout`](https://golang.org/pkg/net/http/#Client) -- [`write_buffer_size`](https://golang.org/pkg/net/http/#Transport) -- `compression`: Compression type to use among `gzip`, `zstd`, `snappy`, `zlib`, and `deflate`. - - look at the documentation for the server-side of the communication. - - `none` will be treated as uncompressed, and any other inputs will cause an error. -- [`max_idle_conns`](https://golang.org/pkg/net/http/#Transport) -- [`max_idle_conns_per_host`](https://golang.org/pkg/net/http/#Transport) -- [`max_conns_per_host`](https://golang.org/pkg/net/http/#Transport) -- [`idle_conn_timeout`](https://golang.org/pkg/net/http/#Transport) -- [`auth`](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configauth/README.md) -- [`disable_keep_alives`](https://golang.org/pkg/net/http/#Transport) - -Example: - -```yaml -exporter: - otlp: - endpoint: otelcol2:55690 - auth: - authenticator: some-authenticator-extension - tls: - ca_file: ca.pem - cert_file: cert.pem - key_file: key.pem - headers: - test1: "value1" - "test 2": "value 2" - compression: zstd -``` - -## Server Configuration - -[Receivers](https://github.com/open-telemetry/opentelemetry-collector/blob/main/receiver/README.md) -leverage server configuration. - -- [`cors`](https://github.com/rs/cors#parameters): Configure [CORS][cors], - allowing the receiver to accept traces from web browsers, even if the receiver - is hosted at a different [origin][origin]. If left blank or set to `null`, CORS - will not be enabled. - - `allowed_origins`: A list of [origins][origin] allowed to send requests to - the receiver. An origin may contain a wildcard (`*`) to replace 0 or more - characters (e.g., `https://*.example.com`). To allow any origin, set to - `["*"]`. If no origins are listed, CORS will not be enabled. - - `allowed_headers`: Allow CORS requests to include headers outside the - [default safelist][cors-headers]. By default, safelist headers and - `X-Requested-With` will be allowed. To allow any request header, set to - `["*"]`. - - `max_age`: Sets the value of the [`Access-Control-Max-Age`][cors-cache] - header, allowing clients to cache the response to CORS preflight requests. If - not set, browsers use a default of 5 seconds. -- `endpoint`: Valid value syntax available [here](https://github.com/grpc/grpc/blob/master/doc/naming.md) -- [`tls`](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configtls/README.md) -- [`auth`](https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/configauth/README.md) - -You can enable [`attribute processor`][attribute-processor] to append any http header to span's attribute using custom key. You also need to enable the "include_metadata" - -Example: - -```yaml -receivers: - otlp: - protocols: - http: - include_metadata: true - auth: - authenticator: some-authenticator-extension - cors: - allowed_origins: - - https://foo.bar.com - - https://*.test.com - allowed_headers: - - Example-Header - max_age: 7200 - endpoint: 0.0.0.0:55690 -processors: - attributes: - actions: - - key: http.client_ip - from_context: X-Forwarded-For - action: upsert -``` - -[cors]: https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS -[cors-headers]: https://developer.mozilla.org/en-US/docs/Glossary/CORS-safelisted_request_header -[cors-cache]: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Access-Control-Max-Age -[origin]: https://developer.mozilla.org/en-US/docs/Glossary/Origin -[attribute-processor]: https://github.com/open-telemetry/opentelemetry-collector-contrib/blob/main/processor/attributesprocessor/README.md diff --git a/config/confighttp/clientinfohandler.go b/config/confighttp/clientinfohandler.go deleted file mode 100644 index 25105cf51a67..000000000000 --- a/config/confighttp/clientinfohandler.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package confighttp // import "go.opentelemetry.io/collector/config/confighttp" - -import ( - "context" - "net" - "net/http" - - "go.opentelemetry.io/collector/client" -) - -var _ http.Handler = (*clientInfoHandler)(nil) - -// clientInfoHandler is an http.Handler that enhances the incoming request context with client.Info. -type clientInfoHandler struct { - next http.Handler - - // include client metadata or not - includeMetadata bool -} - -// ServeHTTP intercepts incoming HTTP requests, replacing the request's context with one that contains -// a client.Info containing the client's IP address. -func (h *clientInfoHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) { - req = req.WithContext(contextWithClient(req, h.includeMetadata)) - h.next.ServeHTTP(w, req) -} - -// contextWithClient attempts to add the client IP address to the client.Info from the context. When no -// client.Info exists in the context, one is created. -func contextWithClient(req *http.Request, includeMetadata bool) context.Context { - cl := client.FromContext(req.Context()) - - ip := parseIP(req.RemoteAddr) - if ip != nil { - cl.Addr = ip - } - - if includeMetadata { - md := req.Header.Clone() - if len(md.Get(client.MetadataHostName)) == 0 && req.Host != "" { - md.Add(client.MetadataHostName, req.Host) - } - - cl.Metadata = client.NewMetadata(md) - } - - ctx := client.NewContext(req.Context(), cl) - return ctx -} - -// parseIP parses the given string for an IP address. The input string might contain the port, -// but must not contain a protocol or path. Suitable for getting the IP part of a client connection. -func parseIP(source string) *net.IPAddr { - ipstr, _, err := net.SplitHostPort(source) - if err == nil { - source = ipstr - } - ip := net.ParseIP(source) - if ip != nil { - return &net.IPAddr{ - IP: ip, - } - } - return nil -} diff --git a/config/confighttp/clientinfohandler_test.go b/config/confighttp/clientinfohandler_test.go deleted file mode 100644 index d8201cad149a..000000000000 --- a/config/confighttp/clientinfohandler_test.go +++ /dev/null @@ -1,49 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package confighttp // import "go.opentelemetry.io/collector/config/confighttp" - -import ( - "net" - "testing" - - "github.com/stretchr/testify/assert" -) - -func TestParseIP(t *testing.T) { - testCases := []struct { - desc string - input string - expected *net.IPAddr - }{ - { - desc: "addr", - input: "1.2.3.4", - expected: &net.IPAddr{ - IP: net.IPv4(1, 2, 3, 4), - }, - }, - { - desc: "addr:port", - input: "1.2.3.4:33455", - expected: &net.IPAddr{ - IP: net.IPv4(1, 2, 3, 4), - }, - }, - { - desc: "protocol://addr:port", - input: "http://1.2.3.4:33455", - expected: nil, - }, - { - desc: "addr/path", - input: "1.2.3.4/orders", - expected: nil, - }, - } - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - assert.Equal(t, tC.expected, parseIP(tC.input)) - }) - } -} diff --git a/config/confighttp/compression.go b/config/confighttp/compression.go deleted file mode 100644 index c3ba03f8fe88..000000000000 --- a/config/confighttp/compression.go +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// This file contains helper functions regarding compression/decompression for confighttp. - -package confighttp // import "go.opentelemetry.io/collector/config/confighttp" - -import ( - "bytes" - "compress/gzip" - "compress/zlib" - "fmt" - "io" - "net/http" - - "github.com/klauspost/compress/zstd" - "go.opentelemetry.io/collector/config/configcompression" -) - -type compressRoundTripper struct { - rt http.RoundTripper - compressionType configcompression.CompressionType - compressor *compressor -} - -func newCompressRoundTripper(rt http.RoundTripper, compressionType configcompression.CompressionType) (*compressRoundTripper, error) { - encoder, err := newCompressor(compressionType) - if err != nil { - return nil, err - } - return &compressRoundTripper{ - rt: rt, - compressionType: compressionType, - compressor: encoder, - }, nil -} - -func (r *compressRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - if req.Header.Get(headerContentEncoding) != "" { - // If the header already specifies a content encoding then skip compression - // since we don't want to compress it again. This is a safeguard that normally - // should not happen since CompressRoundTripper is not intended to be used - // with http clients which already do their own compression. - return r.rt.RoundTrip(req) - } - - // Compress the body. - buf := bytes.NewBuffer([]byte{}) - if err := r.compressor.compress(buf, req.Body); err != nil { - return nil, err - } - - // Create a new request since the docs say that we cannot modify the "req" - // (see https://golang.org/pkg/net/http/#RoundTripper). - cReq, err := http.NewRequestWithContext(req.Context(), req.Method, req.URL.String(), buf) - if err != nil { - return nil, err - } - - // Clone the headers and add the encoding header. - cReq.Header = req.Header.Clone() - cReq.Header.Add(headerContentEncoding, string(r.compressionType)) - - return r.rt.RoundTrip(cReq) -} - -type decompressor struct { - errHandler func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int) - base http.Handler - decoders map[string]func(body io.ReadCloser) (io.ReadCloser, error) -} - -// httpContentDecompressor offloads the task of handling compressed HTTP requests -// by identifying the compression format in the "Content-Encoding" header and re-writing -// request body so that the handlers further in the chain can work on decompressed data. -// It supports gzip and deflate/zlib compression. -func httpContentDecompressor(h http.Handler, eh func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int), decoders map[string]func(body io.ReadCloser) (io.ReadCloser, error)) http.Handler { - errHandler := defaultErrorHandler - if eh != nil { - errHandler = eh - } - - d := &decompressor{ - errHandler: errHandler, - base: h, - decoders: map[string]func(body io.ReadCloser) (io.ReadCloser, error){ - "": func(body io.ReadCloser) (io.ReadCloser, error) { - // Not a compressed payload. Nothing to do. - return nil, nil - }, - "gzip": func(body io.ReadCloser) (io.ReadCloser, error) { - gr, err := gzip.NewReader(body) - if err != nil { - return nil, err - } - return gr, nil - }, - "zstd": func(body io.ReadCloser) (io.ReadCloser, error) { - zr, err := zstd.NewReader( - body, - // Concurrency 1 disables async decoding. We don't need async decoding, it is pointless - // for our use-case (a server accepting decoding http requests). - // Disabling async improves performance (I benchmarked it previously when working - // on https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/23257). - zstd.WithDecoderConcurrency(1), - ) - if err != nil { - return nil, err - } - return zr.IOReadCloser(), nil - }, - "zlib": func(body io.ReadCloser) (io.ReadCloser, error) { - zr, err := zlib.NewReader(body) - if err != nil { - return nil, err - } - return zr, nil - }, - }, - } - d.decoders["deflate"] = d.decoders["zlib"] - - for key, dec := range decoders { - d.decoders[key] = dec - } - - return d -} - -func (d *decompressor) ServeHTTP(w http.ResponseWriter, r *http.Request) { - newBody, err := d.newBodyReader(r) - if err != nil { - d.errHandler(w, r, err.Error(), http.StatusBadRequest) - return - } - if newBody != nil { - defer newBody.Close() - // "Content-Encoding" header is removed to avoid decompressing twice - // in case the next handler(s) have implemented a similar mechanism. - r.Header.Del("Content-Encoding") - // "Content-Length" is set to -1 as the size of the decompressed body is unknown. - r.Header.Del("Content-Length") - r.ContentLength = -1 - r.Body = newBody - } - d.base.ServeHTTP(w, r) -} - -func (d *decompressor) newBodyReader(r *http.Request) (io.ReadCloser, error) { - encoding := r.Header.Get(headerContentEncoding) - decoder, ok := d.decoders[encoding] - if !ok { - return nil, fmt.Errorf("unsupported %s: %s", headerContentEncoding, encoding) - } - return decoder(r.Body) -} - -// defaultErrorHandler writes the error message in plain text. -func defaultErrorHandler(w http.ResponseWriter, _ *http.Request, errMsg string, statusCode int) { - http.Error(w, errMsg, statusCode) -} diff --git a/config/confighttp/compression_test.go b/config/confighttp/compression_test.go deleted file mode 100644 index 4f9a3a695b2a..000000000000 --- a/config/confighttp/compression_test.go +++ /dev/null @@ -1,371 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package confighttp - -import ( - "bytes" - "compress/gzip" - "compress/zlib" - "fmt" - "io" - "net/http" - "net/http/httptest" - "strings" - "testing" - - "github.com/golang/snappy" - "github.com/klauspost/compress/zstd" - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/component/componenttest" - "go.opentelemetry.io/collector/config/configcompression" -) - -func TestHTTPClientCompression(t *testing.T) { - testBody := []byte("uncompressed_text") - compressedGzipBody := compressGzip(t, testBody) - compressedZlibBody := compressZlib(t, testBody) - compressedDeflateBody := compressZlib(t, testBody) - compressedSnappyBody := compressSnappy(t, testBody) - compressedZstdBody := compressZstd(t, testBody) - - tests := []struct { - name string - encoding configcompression.CompressionType - reqBody []byte - shouldError bool - }{ - { - name: "ValidEmpty", - encoding: "", - reqBody: testBody, - shouldError: false, - }, - { - name: "ValidNone", - encoding: "none", - reqBody: testBody, - shouldError: false, - }, - { - name: "ValidGzip", - encoding: configcompression.Gzip, - reqBody: compressedGzipBody.Bytes(), - shouldError: false, - }, - { - name: "ValidZlib", - encoding: configcompression.Zlib, - reqBody: compressedZlibBody.Bytes(), - shouldError: false, - }, - { - name: "ValidDeflate", - encoding: configcompression.Deflate, - reqBody: compressedDeflateBody.Bytes(), - shouldError: false, - }, - { - name: "ValidSnappy", - encoding: configcompression.Snappy, - reqBody: compressedSnappyBody.Bytes(), - shouldError: false, - }, - { - name: "ValidZstd", - encoding: configcompression.Zstd, - reqBody: compressedZstdBody.Bytes(), - shouldError: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - body, err := io.ReadAll(r.Body) - require.NoError(t, err, "failed to read request body: %v", err) - assert.EqualValues(t, tt.reqBody, body) - w.WriteHeader(http.StatusOK) - })) - t.Cleanup(srv.Close) - - reqBody := bytes.NewBuffer(testBody) - - req, err := http.NewRequest(http.MethodGet, srv.URL, reqBody) - require.NoError(t, err, "failed to create request to test handler") - - clientSettings := HTTPClientSettings{ - Endpoint: srv.URL, - Compression: tt.encoding, - } - client, err := clientSettings.ToClient(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) - require.NoError(t, err) - res, err := client.Do(req) - if tt.shouldError { - assert.Error(t, err) - return - } - require.NoError(t, err) - - _, err = io.ReadAll(res.Body) - require.NoError(t, err) - require.NoError(t, res.Body.Close(), "failed to close request body: %v", err) - }) - } -} - -func TestHTTPCustomDecompression(t *testing.T) { - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - body, err := io.ReadAll(r.Body) - if err != nil { - w.WriteHeader(http.StatusBadRequest) - _, _ = w.Write([]byte(err.Error())) - return - } - - require.NoError(t, err, "failed to read request body: %v", err) - assert.EqualValues(t, "decompressed body", string(body)) - w.WriteHeader(http.StatusOK) - }) - decoders := map[string]func(io.ReadCloser) (io.ReadCloser, error){ - "custom-encoding": func(io.ReadCloser) (io.ReadCloser, error) { // nolint: unparam - return io.NopCloser(strings.NewReader("decompressed body")), nil - }, - } - srv := httptest.NewServer(httpContentDecompressor(handler, defaultErrorHandler, decoders)) - - t.Cleanup(srv.Close) - - req, err := http.NewRequest(http.MethodGet, srv.URL, bytes.NewBuffer([]byte("123decompressed body"))) - require.NoError(t, err, "failed to create request to test handler") - req.Header.Set("Content-Encoding", "custom-encoding") - - client := http.Client{} - res, err := client.Do(req) - require.NoError(t, err) - - assert.Equal(t, http.StatusOK, res.StatusCode, "test handler returned unexpected status code ") - _, err = io.ReadAll(res.Body) - require.NoError(t, res.Body.Close(), "failed to close request body: %v", err) -} - -func TestHTTPContentDecompressionHandler(t *testing.T) { - testBody := []byte("uncompressed_text") - noDecoders := map[string]func(io.ReadCloser) (io.ReadCloser, error){} - tests := []struct { - name string - encoding string - reqBody *bytes.Buffer - respCode int - respBody string - }{ - { - name: "NoCompression", - encoding: "", - reqBody: bytes.NewBuffer(testBody), - respCode: http.StatusOK, - }, - { - name: "ValidDeflate", - encoding: "deflate", - reqBody: compressZlib(t, testBody), - respCode: http.StatusOK, - }, - { - name: "ValidGzip", - encoding: "gzip", - reqBody: compressGzip(t, testBody), - respCode: http.StatusOK, - }, - { - name: "ValidZlib", - encoding: "zlib", - reqBody: compressZlib(t, testBody), - respCode: http.StatusOK, - }, - { - name: "ValidZstd", - encoding: "zstd", - reqBody: compressZstd(t, testBody), - respCode: http.StatusOK, - }, - { - name: "InvalidDeflate", - encoding: "deflate", - reqBody: bytes.NewBuffer(testBody), - respCode: http.StatusBadRequest, - respBody: "zlib: invalid header\n", - }, - { - name: "InvalidGzip", - encoding: "gzip", - reqBody: bytes.NewBuffer(testBody), - respCode: http.StatusBadRequest, - respBody: "gzip: invalid header\n", - }, - { - name: "InvalidZlib", - encoding: "zlib", - reqBody: bytes.NewBuffer(testBody), - respCode: http.StatusBadRequest, - respBody: "zlib: invalid header\n", - }, - { - name: "InvalidZstd", - encoding: "zstd", - reqBody: bytes.NewBuffer(testBody), - respCode: http.StatusBadRequest, - respBody: "invalid input: magic number mismatch", - }, - { - name: "UnsupportedCompression", - encoding: "nosuchcompression", - reqBody: bytes.NewBuffer(testBody), - respCode: http.StatusBadRequest, - respBody: "unsupported Content-Encoding: nosuchcompression\n", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - srv := httptest.NewServer(httpContentDecompressor(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - body, err := io.ReadAll(r.Body) - if err != nil { - w.WriteHeader(http.StatusBadRequest) - _, _ = w.Write([]byte(err.Error())) - return - } - - require.NoError(t, err, "failed to read request body: %v", err) - assert.EqualValues(t, testBody, string(body)) - w.WriteHeader(http.StatusOK) - }), defaultErrorHandler, noDecoders)) - t.Cleanup(srv.Close) - - req, err := http.NewRequest(http.MethodGet, srv.URL, tt.reqBody) - require.NoError(t, err, "failed to create request to test handler") - req.Header.Set("Content-Encoding", tt.encoding) - - client := http.Client{} - res, err := client.Do(req) - require.NoError(t, err) - - assert.Equal(t, tt.respCode, res.StatusCode, "test handler returned unexpected status code ") - if tt.respBody != "" { - body, err := io.ReadAll(res.Body) - require.NoError(t, res.Body.Close(), "failed to close request body: %v", err) - assert.Equal(t, tt.respBody, string(body)) - } - }) - } -} - -func TestHTTPContentCompressionRequestWithNilBody(t *testing.T) { - compressedGzipBody := compressGzip(t, []byte{}) - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - body, err := io.ReadAll(r.Body) - require.NoError(t, err, "failed to read request body: %v", err) - assert.EqualValues(t, compressedGzipBody.Bytes(), body) - })) - defer server.Close() - - req, err := http.NewRequest(http.MethodGet, server.URL, nil) - require.NoError(t, err, "failed to create request to test handler") - - client := http.Client{} - client.Transport, err = newCompressRoundTripper(http.DefaultTransport, configcompression.Gzip) - require.NoError(t, err) - res, err := client.Do(req) - require.NoError(t, err) - - _, err = io.ReadAll(res.Body) - require.NoError(t, err) - require.NoError(t, res.Body.Close(), "failed to close request body: %v", err) -} - -type copyFailBody struct { -} - -func (*copyFailBody) Read(_ []byte) (n int, err error) { - return 0, fmt.Errorf("read failed") -} - -func (*copyFailBody) Close() error { - return nil -} - -func TestHTTPContentCompressionCopyError(t *testing.T) { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - })) - t.Cleanup(server.Close) - - req, err := http.NewRequest(http.MethodGet, server.URL, ©FailBody{}) - require.NoError(t, err) - - client := http.Client{} - client.Transport, err = newCompressRoundTripper(http.DefaultTransport, configcompression.Gzip) - require.NoError(t, err) - _, err = client.Do(req) - require.Error(t, err) -} - -type closeFailBody struct { - *bytes.Buffer -} - -func (*closeFailBody) Close() error { - return fmt.Errorf("close failed") -} - -func TestHTTPContentCompressionRequestBodyCloseError(t *testing.T) { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - })) - t.Cleanup(server.Close) - - req, err := http.NewRequest(http.MethodGet, server.URL, &closeFailBody{Buffer: bytes.NewBuffer([]byte("blank"))}) - require.NoError(t, err) - - client := http.Client{} - client.Transport, err = newCompressRoundTripper(http.DefaultTransport, configcompression.Gzip) - require.NoError(t, err) - _, err = client.Do(req) - require.Error(t, err) -} - -func compressGzip(t testing.TB, body []byte) *bytes.Buffer { - var buf bytes.Buffer - gw := gzip.NewWriter(&buf) - _, err := gw.Write(body) - require.NoError(t, err) - require.NoError(t, gw.Close()) - return &buf -} - -func compressZlib(t testing.TB, body []byte) *bytes.Buffer { - var buf bytes.Buffer - zw := zlib.NewWriter(&buf) - _, err := zw.Write(body) - require.NoError(t, err) - require.NoError(t, zw.Close()) - return &buf -} - -func compressSnappy(t testing.TB, body []byte) *bytes.Buffer { - var buf bytes.Buffer - sw := snappy.NewBufferedWriter(&buf) - _, err := sw.Write(body) - require.NoError(t, err) - require.NoError(t, sw.Close()) - return &buf -} - -func compressZstd(t testing.TB, body []byte) *bytes.Buffer { - var buf bytes.Buffer - zw, _ := zstd.NewWriter(&buf) - _, err := zw.Write(body) - require.NoError(t, err) - require.NoError(t, zw.Close()) - return &buf -} diff --git a/config/confighttp/compressor.go b/config/confighttp/compressor.go deleted file mode 100644 index 341808d503e8..000000000000 --- a/config/confighttp/compressor.go +++ /dev/null @@ -1,74 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package confighttp // import "go.opentelemetry.io/collector/config/confighttp" - -import ( - "bytes" - "compress/gzip" - "compress/zlib" - "errors" - "io" - "sync" - - "github.com/golang/snappy" - "github.com/klauspost/compress/zstd" - "go.opentelemetry.io/collector/config/configcompression" -) - -type writeCloserReset interface { - io.WriteCloser - Reset(w io.Writer) -} - -var ( - _ writeCloserReset = (*gzip.Writer)(nil) - gZipPool = &compressor{pool: sync.Pool{New: func() any { return gzip.NewWriter(nil) }}} - _ writeCloserReset = (*snappy.Writer)(nil) - snappyPool = &compressor{pool: sync.Pool{New: func() any { return snappy.NewBufferedWriter(nil) }}} - _ writeCloserReset = (*zstd.Encoder)(nil) - zStdPool = &compressor{pool: sync.Pool{New: func() any { zw, _ := zstd.NewWriter(nil); return zw }}} - _ writeCloserReset = (*zlib.Writer)(nil) - zLibPool = &compressor{pool: sync.Pool{New: func() any { return zlib.NewWriter(nil) }}} -) - -type compressor struct { - pool sync.Pool -} - -// writerFactory defines writer field in CompressRoundTripper. -// The validity of input is already checked when NewCompressRoundTripper was called in confighttp, -func newCompressor(compressionType configcompression.CompressionType) (*compressor, error) { - switch compressionType { - case configcompression.Gzip: - return gZipPool, nil - case configcompression.Snappy: - return snappyPool, nil - case configcompression.Zstd: - return zStdPool, nil - case configcompression.Zlib, configcompression.Deflate: - return zLibPool, nil - } - return nil, errors.New("unsupported compression type, ") -} - -func (p *compressor) compress(buf *bytes.Buffer, body io.ReadCloser) error { - writer := p.pool.Get().(writeCloserReset) - defer p.pool.Put(writer) - writer.Reset(buf) - - if body != nil { - _, copyErr := io.Copy(writer, body) - closeErr := body.Close() - - if copyErr != nil { - return copyErr - } - - if closeErr != nil { - return closeErr - } - } - - return writer.Close() -} diff --git a/config/confighttp/confighttp.go b/config/confighttp/confighttp.go deleted file mode 100644 index 2b7d41f247ed..000000000000 --- a/config/confighttp/confighttp.go +++ /dev/null @@ -1,401 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package confighttp // import "go.opentelemetry.io/collector/config/confighttp" - -import ( - "crypto/tls" - "errors" - "io" - "net" - "net/http" - "time" - - "github.com/rs/cors" - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/config/configauth" - "go.opentelemetry.io/collector/config/configcompression" - "go.opentelemetry.io/collector/config/configopaque" - "go.opentelemetry.io/collector/config/configtls" - "go.opentelemetry.io/collector/config/internal" - "go.opentelemetry.io/collector/extension/auth" - "go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp" - "go.opentelemetry.io/otel" - "golang.org/x/net/http2" -) - -const headerContentEncoding = "Content-Encoding" - -// HTTPClientSettings defines settings for creating an HTTP client. -type HTTPClientSettings struct { - // The target URL to send data to (e.g.: http://some.url:9411/v1/traces). - Endpoint string `mapstructure:"endpoint"` - - // TLSSetting struct exposes TLS client configuration. - TLSSetting configtls.TLSClientSetting `mapstructure:"tls,omitempty"` - - // ReadBufferSize for HTTP client. See http.Transport.ReadBufferSize. - ReadBufferSize int `mapstructure:"read_buffer_size"` - - // WriteBufferSize for HTTP client. See http.Transport.WriteBufferSize. - WriteBufferSize int `mapstructure:"write_buffer_size"` - - // Timeout parameter configures `http.Client.Timeout`. - Timeout time.Duration `mapstructure:"timeout"` - - // Additional headers attached to each HTTP request sent by the client. - // Existing header values are overwritten if collision happens. - // Header values are opaque since they may be sensitive. - Headers map[string]configopaque.String `mapstructure:"headers"` - - // Custom Round Tripper to allow for individual components to intercept HTTP requests - CustomRoundTripper func(next http.RoundTripper) (http.RoundTripper, error) `mapstructure:"-"` - - // Auth configuration for outgoing HTTP calls. - Auth *configauth.Authentication `mapstructure:"auth"` - - // The compression key for supported compression types within collector. - Compression configcompression.CompressionType `mapstructure:"compression"` - - // MaxIdleConns is used to set a limit to the maximum idle HTTP connections the client can keep open. - // There's an already set value, and we want to override it only if an explicit value provided - MaxIdleConns *int `mapstructure:"max_idle_conns"` - - // MaxIdleConnsPerHost is used to set a limit to the maximum idle HTTP connections the host can keep open. - // There's an already set value, and we want to override it only if an explicit value provided - MaxIdleConnsPerHost *int `mapstructure:"max_idle_conns_per_host"` - - // MaxConnsPerHost limits the total number of connections per host, including connections in the dialing, - // active, and idle states. - // There's an already set value, and we want to override it only if an explicit value provided - MaxConnsPerHost *int `mapstructure:"max_conns_per_host"` - - // IdleConnTimeout is the maximum amount of time a connection will remain open before closing itself. - // There's an already set value, and we want to override it only if an explicit value provided - IdleConnTimeout *time.Duration `mapstructure:"idle_conn_timeout"` - - // DisableKeepAlives, if true, disables HTTP keep-alives and will only use the connection to the server - // for a single HTTP request. - // - // WARNING: enabling this option can result in significant overhead establishing a new HTTP(S) - // connection for every request. Before enabling this option please consider whether changes - // to idle connection settings can achieve your goal. - DisableKeepAlives bool `mapstructure:"disable_keep_alives"` -} - -// NewDefaultHTTPClientSettings returns HTTPClientSettings 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 HTTPClientSettings. -func NewDefaultHTTPClientSettings() HTTPClientSettings { - // The default values are taken from the values of 'DefaultTransport' of 'http' package. - maxIdleConns := 100 - idleConnTimeout := 90 * time.Second - - return HTTPClientSettings{ - MaxIdleConns: &maxIdleConns, - IdleConnTimeout: &idleConnTimeout, - } -} - -// ToClient creates an HTTP client. -func (hcs *HTTPClientSettings) ToClient(host component.Host, settings component.TelemetrySettings) (*http.Client, error) { - tlsCfg, err := hcs.TLSSetting.LoadTLSConfig() - if err != nil { - return nil, err - } - transport := http.DefaultTransport.(*http.Transport).Clone() - if tlsCfg != nil { - transport.TLSClientConfig = tlsCfg - } - if hcs.ReadBufferSize > 0 { - transport.ReadBufferSize = hcs.ReadBufferSize - } - if hcs.WriteBufferSize > 0 { - transport.WriteBufferSize = hcs.WriteBufferSize - } - - if hcs.MaxIdleConns != nil { - transport.MaxIdleConns = *hcs.MaxIdleConns - } - - if hcs.MaxIdleConnsPerHost != nil { - transport.MaxIdleConnsPerHost = *hcs.MaxIdleConnsPerHost - } - - if hcs.MaxConnsPerHost != nil { - transport.MaxConnsPerHost = *hcs.MaxConnsPerHost - } - - if hcs.IdleConnTimeout != nil { - transport.IdleConnTimeout = *hcs.IdleConnTimeout - } - - transport.DisableKeepAlives = hcs.DisableKeepAlives - - clientTransport := (http.RoundTripper)(transport) - - // The Auth RoundTripper should always be the innermost to ensure that - // request signing-based auth mechanisms operate after compression - // and header middleware modifies the request - if hcs.Auth != nil { - ext := host.GetExtensions() - if ext == nil { - return nil, errors.New("extensions configuration not found") - } - - httpCustomAuthRoundTripper, aerr := hcs.Auth.GetClientAuthenticator(ext) - if aerr != nil { - return nil, aerr - } - - clientTransport, err = httpCustomAuthRoundTripper.RoundTripper(clientTransport) - if err != nil { - return nil, err - } - } - - if len(hcs.Headers) > 0 { - clientTransport = &headerRoundTripper{ - transport: clientTransport, - headers: hcs.Headers, - } - } - - // Compress the body using specified compression methods if non-empty string is provided. - // Supporting gzip, zlib, deflate, snappy, and zstd; none is treated as uncompressed. - if configcompression.IsCompressed(hcs.Compression) { - clientTransport, err = newCompressRoundTripper(clientTransport, hcs.Compression) - if err != nil { - return nil, err - } - } - - // wrapping http transport with otelhttp transport to enable otel instrumentation - if settings.TracerProvider != nil && settings.MeterProvider != nil { - clientTransport = otelhttp.NewTransport( - clientTransport, - otelhttp.WithTracerProvider(settings.TracerProvider), - otelhttp.WithMeterProvider(settings.MeterProvider), - otelhttp.WithPropagators(otel.GetTextMapPropagator()), - ) - } - - if hcs.CustomRoundTripper != nil { - clientTransport, err = hcs.CustomRoundTripper(clientTransport) - if err != nil { - return nil, err - } - } - - return &http.Client{ - Transport: clientTransport, - Timeout: hcs.Timeout, - }, nil -} - -// Custom RoundTripper that adds headers. -type headerRoundTripper struct { - transport http.RoundTripper - headers map[string]configopaque.String -} - -// RoundTrip is a custom RoundTripper that adds headers to the request. -func (interceptor *headerRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { - for k, v := range interceptor.headers { - req.Header.Set(k, string(v)) - } - // Send the request to next transport. - return interceptor.transport.RoundTrip(req) -} - -// HTTPServerSettings defines settings for creating an HTTP server. -type HTTPServerSettings struct { - // Endpoint configures the listening address for the server. - Endpoint string `mapstructure:"endpoint"` - - // TLSSetting struct exposes TLS client configuration. - TLSSetting *configtls.TLSServerSetting `mapstructure:"tls"` - - // CORS configures the server for HTTP cross-origin resource sharing (CORS). - CORS *CORSSettings `mapstructure:"cors"` - - // Auth for this receiver - Auth *configauth.Authentication `mapstructure:"auth"` - - // MaxRequestBodySize sets the maximum request body size in bytes - MaxRequestBodySize int64 `mapstructure:"max_request_body_size"` - - // IncludeMetadata propagates the client metadata from the incoming requests to the downstream consumers - // Experimental: *NOTE* this option is subject to change or removal in the future. - IncludeMetadata bool `mapstructure:"include_metadata"` - - // Additional headers attached to each HTTP response sent to the client. - // Header values are opaque since they may be sensitive. - ResponseHeaders map[string]configopaque.String `mapstructure:"response_headers"` -} - -// ToListener creates a net.Listener. -func (hss *HTTPServerSettings) ToListener() (net.Listener, error) { - listener, err := net.Listen("tcp", hss.Endpoint) - if err != nil { - return nil, err - } - - if hss.TLSSetting != nil { - var tlsCfg *tls.Config - tlsCfg, err = hss.TLSSetting.LoadTLSConfig() - if err != nil { - return nil, err - } - tlsCfg.NextProtos = []string{http2.NextProtoTLS, "http/1.1"} - listener = tls.NewListener(listener, tlsCfg) - } - return listener, nil -} - -// toServerOptions has options that change the behavior of the HTTP server -// returned by HTTPServerSettings.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 HTTPServerSettings.ToServer(). -type ToServerOption func(opts *toServerOptions) - -// WithErrorHandler overrides the HTTP error handler that gets invoked -// when there is a failure inside httpContentDecompressor. -func WithErrorHandler(e func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int)) ToServerOption { - return func(opts *toServerOptions) { - opts.errHandler = e - } -} - -// WithDecoder provides support for additional decoders to be configured -// by the caller. -func WithDecoder(key string, dec func(body io.ReadCloser) (io.ReadCloser, error)) ToServerOption { - return func(opts *toServerOptions) { - if opts.decoders == nil { - opts.decoders = map[string]func(body io.ReadCloser) (io.ReadCloser, error){} - } - opts.decoders[key] = dec - } -} - -// ToServer creates an http.Server from settings object. -func (hss *HTTPServerSettings) ToServer(host component.Host, settings component.TelemetrySettings, handler http.Handler, opts ...ToServerOption) (*http.Server, error) { - internal.WarnOnUnspecifiedHost(settings.Logger, hss.Endpoint) - - serverOpts := &toServerOptions{} - for _, o := range opts { - o(serverOpts) - } - - handler = httpContentDecompressor(handler, serverOpts.errHandler, serverOpts.decoders) - - if hss.MaxRequestBodySize > 0 { - handler = maxRequestBodySizeInterceptor(handler, hss.MaxRequestBodySize) - } - - if hss.Auth != nil { - server, err := hss.Auth.GetServerAuthenticator(host.GetExtensions()) - if err != nil { - return nil, err - } - - handler = authInterceptor(handler, server) - } - - // TODO: emit a warning when non-empty CorsHeaders and empty CorsOrigins. - if hss.CORS != nil && len(hss.CORS.AllowedOrigins) > 0 { - co := cors.Options{ - AllowedOrigins: hss.CORS.AllowedOrigins, - AllowCredentials: true, - AllowedHeaders: hss.CORS.AllowedHeaders, - MaxAge: hss.CORS.MaxAge, - } - handler = cors.New(co).Handler(handler) - } - - if hss.ResponseHeaders != nil { - handler = responseHeadersHandler(handler, hss.ResponseHeaders) - } - - // Enable OpenTelemetry observability plugin. - // TODO: Consider to use component ID string as prefix for all the operations. - handler = otelhttp.NewHandler( - handler, - "", - otelhttp.WithTracerProvider(settings.TracerProvider), - otelhttp.WithMeterProvider(settings.MeterProvider), - otelhttp.WithPropagators(otel.GetTextMapPropagator()), - otelhttp.WithSpanNameFormatter(func(operation string, r *http.Request) string { - return r.URL.Path - }), - ) - - // wrap the current handler in an interceptor that will add client.Info to the request's context - handler = &clientInfoHandler{ - next: handler, - includeMetadata: hss.IncludeMetadata, - } - - return &http.Server{ - Handler: handler, - }, nil -} - -func responseHeadersHandler(handler http.Handler, headers map[string]configopaque.String) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - h := w.Header() - - for k, v := range headers { - h.Set(k, string(v)) - } - - handler.ServeHTTP(w, r) - }) -} - -// CORSSettings configures a receiver for HTTP cross-origin resource sharing (CORS). -// See the underlying https://github.com/rs/cors package for details. -type CORSSettings struct { - // AllowedOrigins sets the allowed values of the Origin header for - // HTTP/JSON requests to an OTLP receiver. An origin may contain a - // wildcard (*) to replace 0 or more characters (e.g., - // "http://*.domain.com", or "*" to allow any origin). - AllowedOrigins []string `mapstructure:"allowed_origins"` - - // AllowedHeaders sets what headers will be allowed in CORS requests. - // The Accept, Accept-Language, Content-Type, and Content-Language - // headers are implicitly allowed. If no headers are listed, - // X-Requested-With will also be accepted by default. Include "*" to - // allow any request header. - AllowedHeaders []string `mapstructure:"allowed_headers"` - - // MaxAge sets the value of the Access-Control-Max-Age response header. - // Set it to the number of seconds that browsers should cache a CORS - // preflight response for. - MaxAge int `mapstructure:"max_age"` -} - -func authInterceptor(next http.Handler, server auth.Server) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - ctx, err := server.Authenticate(r.Context(), r.Header) - if err != nil { - http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized) - return - } - - next.ServeHTTP(w, r.WithContext(ctx)) - }) -} - -func maxRequestBodySizeInterceptor(next http.Handler, maxRecvSize int64) http.Handler { - return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - r.Body = http.MaxBytesReader(w, r.Body, maxRecvSize) - next.ServeHTTP(w, r) - }) -} diff --git a/config/confighttp/confighttp_test.go b/config/confighttp/confighttp_test.go deleted file mode 100644 index e109087febe4..000000000000 --- a/config/confighttp/confighttp_test.go +++ /dev/null @@ -1,1304 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -package confighttp - -import ( - "context" - "errors" - "fmt" - "io" - "net" - "net/http" - "net/http/httptest" - "net/url" - "path/filepath" - "testing" - "time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "go.opentelemetry.io/collector/client" - "go.opentelemetry.io/collector/component" - "go.opentelemetry.io/collector/component/componenttest" - "go.opentelemetry.io/collector/config/configauth" - "go.opentelemetry.io/collector/config/configcompression" - "go.opentelemetry.io/collector/config/configopaque" - "go.opentelemetry.io/collector/config/configtelemetry" - "go.opentelemetry.io/collector/config/configtls" - "go.opentelemetry.io/collector/extension/auth" - "go.opentelemetry.io/collector/extension/auth/authtest" - "go.uber.org/zap" - "go.uber.org/zap/zaptest/observer" -) - -type customRoundTripper struct { -} - -var _ http.RoundTripper = (*customRoundTripper)(nil) - -func (c *customRoundTripper) RoundTrip(_ *http.Request) (*http.Response, error) { - return nil, nil -} - -func TestAllHTTPClientSettings(t *testing.T) { - host := &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("testauth"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, - }, - } - - maxIdleConns := 50 - maxIdleConnsPerHost := 40 - maxConnsPerHost := 45 - idleConnTimeout := 30 * time.Second - tests := []struct { - name string - settings HTTPClientSettings - shouldError bool - }{ - { - name: "all_valid_settings", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - TLSSetting: configtls.TLSClientSetting{ - Insecure: false, - }, - ReadBufferSize: 1024, - WriteBufferSize: 512, - MaxIdleConns: &maxIdleConns, - MaxIdleConnsPerHost: &maxIdleConnsPerHost, - MaxConnsPerHost: &maxConnsPerHost, - IdleConnTimeout: &idleConnTimeout, - CustomRoundTripper: func(next http.RoundTripper) (http.RoundTripper, error) { return next, nil }, - Compression: "", - DisableKeepAlives: true, - }, - shouldError: false, - }, - { - name: "all_valid_settings_with_none_compression", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - TLSSetting: configtls.TLSClientSetting{ - Insecure: false, - }, - ReadBufferSize: 1024, - WriteBufferSize: 512, - MaxIdleConns: &maxIdleConns, - MaxIdleConnsPerHost: &maxIdleConnsPerHost, - MaxConnsPerHost: &maxConnsPerHost, - IdleConnTimeout: &idleConnTimeout, - CustomRoundTripper: func(next http.RoundTripper) (http.RoundTripper, error) { return next, nil }, - Compression: "none", - DisableKeepAlives: true, - }, - shouldError: false, - }, - { - name: "all_valid_settings_with_gzip_compression", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - TLSSetting: configtls.TLSClientSetting{ - Insecure: false, - }, - ReadBufferSize: 1024, - WriteBufferSize: 512, - MaxIdleConns: &maxIdleConns, - MaxIdleConnsPerHost: &maxIdleConnsPerHost, - MaxConnsPerHost: &maxConnsPerHost, - IdleConnTimeout: &idleConnTimeout, - CustomRoundTripper: func(next http.RoundTripper) (http.RoundTripper, error) { return next, nil }, - Compression: "gzip", - DisableKeepAlives: true, - }, - shouldError: false, - }, - { - name: "error_round_tripper_returned", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - TLSSetting: configtls.TLSClientSetting{ - Insecure: false, - }, - ReadBufferSize: 1024, - WriteBufferSize: 512, - CustomRoundTripper: func(next http.RoundTripper) (http.RoundTripper, error) { return nil, errors.New("error") }, - }, - shouldError: true, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - tt := componenttest.NewNopTelemetrySettings() - tt.TracerProvider = nil - client, err := test.settings.ToClient(host, tt) - if test.shouldError { - assert.Error(t, err) - return - } - assert.NoError(t, err) - switch transport := client.Transport.(type) { - case *http.Transport: - assert.EqualValues(t, 1024, transport.ReadBufferSize) - assert.EqualValues(t, 512, transport.WriteBufferSize) - assert.EqualValues(t, 50, transport.MaxIdleConns) - assert.EqualValues(t, 40, transport.MaxIdleConnsPerHost) - assert.EqualValues(t, 45, transport.MaxConnsPerHost) - assert.EqualValues(t, 30*time.Second, transport.IdleConnTimeout) - assert.EqualValues(t, true, transport.DisableKeepAlives) - case *compressRoundTripper: - assert.EqualValues(t, "gzip", transport.compressionType) - } - }) - } -} - -func TestPartialHTTPClientSettings(t *testing.T) { - host := &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("testauth"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, - }, - } - - tests := []struct { - name string - settings HTTPClientSettings - shouldError bool - }{ - { - name: "valid_partial_settings", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - TLSSetting: configtls.TLSClientSetting{ - Insecure: false, - }, - ReadBufferSize: 1024, - WriteBufferSize: 512, - CustomRoundTripper: func(next http.RoundTripper) (http.RoundTripper, error) { return next, nil }, - }, - shouldError: false, - }, - } - - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - tt := componenttest.NewNopTelemetrySettings() - tt.TracerProvider = nil - client, err := test.settings.ToClient(host, tt) - assert.NoError(t, err) - transport := client.Transport.(*http.Transport) - assert.EqualValues(t, 1024, transport.ReadBufferSize) - assert.EqualValues(t, 512, transport.WriteBufferSize) - assert.EqualValues(t, 100, transport.MaxIdleConns) - assert.EqualValues(t, 0, transport.MaxIdleConnsPerHost) - assert.EqualValues(t, 0, transport.MaxConnsPerHost) - assert.EqualValues(t, 90*time.Second, transport.IdleConnTimeout) - assert.EqualValues(t, false, transport.DisableKeepAlives) - - }) - } -} - -func TestDefaultHTTPClientSettings(t *testing.T) { - httpClientSettings := NewDefaultHTTPClientSettings() - assert.EqualValues(t, 100, *httpClientSettings.MaxIdleConns) - assert.EqualValues(t, 90*time.Second, *httpClientSettings.IdleConnTimeout) -} - -func TestHTTPClientSettingsError(t *testing.T) { - host := &mockHost{ - ext: map[component.ID]component.Component{}, - } - tests := []struct { - settings HTTPClientSettings - err string - }{ - { - err: "^failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:", - settings: HTTPClientSettings{ - Endpoint: "", - TLSSetting: configtls.TLSClientSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: "/doesnt/exist", - }, - Insecure: false, - ServerName: "", - }, - }, - }, - { - err: "^failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither", - settings: HTTPClientSettings{ - Endpoint: "", - TLSSetting: configtls.TLSClientSetting{ - TLSSetting: configtls.TLSSetting{ - CertFile: "/doesnt/exist", - }, - Insecure: false, - ServerName: "", - }, - }, - }, - { - err: "failed to resolve authenticator \"dummy\": authenticator not found", - settings: HTTPClientSettings{ - Endpoint: "https://localhost:1234/v1/traces", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("dummy")}, - }, - }, - } - for _, test := range tests { - t.Run(test.err, func(t *testing.T) { - _, err := test.settings.ToClient(host, componenttest.NewNopTelemetrySettings()) - assert.Regexp(t, test.err, err) - }) - } -} - -func TestHTTPClientSettingWithAuthConfig(t *testing.T) { - tests := []struct { - name string - shouldErr bool - settings HTTPClientSettings - host component.Host - }{ - { - name: "no_auth_extension_enabled", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - Auth: nil, - }, - shouldErr: false, - host: &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ - ResultRoundTripper: &customRoundTripper{}, - }, - }, - }, - }, - { - name: "with_auth_configuration_and_no_extension", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("dummy")}, - }, - shouldErr: true, - host: &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, - }, - }, - }, - { - name: "with_auth_configuration_and_no_extension_map", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("dummy")}, - }, - shouldErr: true, - host: componenttest.NewNopHost(), - }, - { - name: "with_auth_configuration_has_extension", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("mock")}, - }, - shouldErr: false, - host: &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, - }, - }, - }, - { - name: "with_auth_configuration_has_extension_and_headers", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("mock")}, - Headers: map[string]configopaque.String{"foo": "bar"}, - }, - shouldErr: false, - host: &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, - }, - }, - }, - { - name: "with_auth_configuration_has_extension_and_compression", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("mock")}, - Compression: configcompression.Gzip, - }, - shouldErr: false, - host: &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ResultRoundTripper: &customRoundTripper{}}, - }, - }, - }, - { - name: "with_auth_configuration_has_err_extension", - settings: HTTPClientSettings{ - Endpoint: "localhost:1234", - Auth: &configauth.Authentication{AuthenticatorID: component.NewID("mock")}, - }, - shouldErr: true, - host: &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("mock"): &authtest.MockClient{ - ResultRoundTripper: &customRoundTripper{}, MustError: true}, - }, - }, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - // Omit TracerProvider and MeterProvider in TelemetrySettings as otelhttp.Transport cannot be introspected - client, err := test.settings.ToClient(test.host, component.TelemetrySettings{Logger: zap.NewNop(), MetricsLevel: configtelemetry.LevelNone}) - if test.shouldErr { - assert.Error(t, err) - return - } - assert.NoError(t, err) - assert.NotNil(t, client) - transport := client.Transport - - // Compression should wrap Auth, unwrap it - if configcompression.IsCompressed(test.settings.Compression) { - ct, ok := transport.(*compressRoundTripper) - assert.True(t, ok) - assert.Equal(t, test.settings.Compression, ct.compressionType) - transport = ct.rt - } - - // Headers should wrap Auth, unwrap it - if test.settings.Headers != nil { - ht, ok := transport.(*headerRoundTripper) - assert.True(t, ok) - assert.Equal(t, test.settings.Headers, ht.headers) - transport = ht.transport - } - - if test.settings.Auth != nil { - _, ok := transport.(*customRoundTripper) - assert.True(t, ok) - } - }) - } -} - -func TestHTTPServerSettingsError(t *testing.T) { - tests := []struct { - settings HTTPServerSettings - err string - }{ - { - err: "^failed to load TLS config: failed to load CA CertPool File: failed to load cert /doesnt/exist:", - settings: HTTPServerSettings{ - Endpoint: "localhost:0", - TLSSetting: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: "/doesnt/exist", - }, - }, - }, - }, - { - err: "^failed to load TLS config: failed to load TLS cert and key: for auth via TLS, provide both certificate and key, or neither", - settings: HTTPServerSettings{ - Endpoint: "localhost:0", - TLSSetting: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CertFile: "/doesnt/exist", - }, - }, - }, - }, - { - err: "failed to load client CA CertPool: failed to load CA /doesnt/exist:", - settings: HTTPServerSettings{ - Endpoint: "localhost:0", - TLSSetting: &configtls.TLSServerSetting{ - ClientCAFile: "/doesnt/exist", - }, - }, - }, - } - for _, test := range tests { - t.Run(test.err, func(t *testing.T) { - _, err := test.settings.ToListener() - assert.Regexp(t, test.err, err) - }) - } -} - -func TestHTTPServerWarning(t *testing.T) { - tests := []struct { - name string - settings HTTPServerSettings - len int - }{ - { - settings: HTTPServerSettings{ - Endpoint: "0.0.0.0:0", - }, - len: 1, - }, - { - settings: HTTPServerSettings{ - Endpoint: "127.0.0.1:0", - }, - len: 0, - }, - } - for _, test := range tests { - t.Run(test.name, func(t *testing.T) { - set := componenttest.NewNopTelemetrySettings() - logger, observed := observer.New(zap.DebugLevel) - set.Logger = zap.New(logger) - - _, err := test.settings.ToServer( - componenttest.NewNopHost(), - set, - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, errWrite := fmt.Fprint(w, "test") - assert.NoError(t, errWrite) - })) - require.NoError(t, err) - require.Len(t, observed.FilterLevelExact(zap.WarnLevel).All(), test.len) - }) - } - -} - -func TestHttpReception(t *testing.T) { - tests := []struct { - name string - tlsServerCreds *configtls.TLSServerSetting - tlsClientCreds *configtls.TLSClientSetting - hasError bool - forceHTTP1 bool - }{ - { - name: "noTLS", - tlsServerCreds: nil, - tlsClientCreds: &configtls.TLSClientSetting{ - Insecure: true, - }, - }, - { - name: "TLS", - tlsServerCreds: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - CertFile: filepath.Join("testdata", "server.crt"), - KeyFile: filepath.Join("testdata", "server.key"), - }, - }, - tlsClientCreds: &configtls.TLSClientSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - }, - ServerName: "localhost", - }, - }, - { - name: "TLS (HTTP/1.1)", - tlsServerCreds: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - CertFile: filepath.Join("testdata", "server.crt"), - KeyFile: filepath.Join("testdata", "server.key"), - }, - }, - tlsClientCreds: &configtls.TLSClientSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - }, - ServerName: "localhost", - }, - forceHTTP1: true, - }, - { - name: "NoServerCertificates", - tlsServerCreds: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - }, - }, - tlsClientCreds: &configtls.TLSClientSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - }, - ServerName: "localhost", - }, - hasError: true, - }, - { - name: "mTLS", - tlsServerCreds: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - CertFile: filepath.Join("testdata", "server.crt"), - KeyFile: filepath.Join("testdata", "server.key"), - }, - ClientCAFile: filepath.Join("testdata", "ca.crt"), - }, - tlsClientCreds: &configtls.TLSClientSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - CertFile: filepath.Join("testdata", "client.crt"), - KeyFile: filepath.Join("testdata", "client.key"), - }, - ServerName: "localhost", - }, - }, - { - name: "NoClientCertificate", - tlsServerCreds: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - CertFile: filepath.Join("testdata", "server.crt"), - KeyFile: filepath.Join("testdata", "server.key"), - }, - ClientCAFile: filepath.Join("testdata", "ca.crt"), - }, - tlsClientCreds: &configtls.TLSClientSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - }, - ServerName: "localhost", - }, - hasError: true, - }, - { - name: "WrongClientCA", - tlsServerCreds: &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - CertFile: filepath.Join("testdata", "server.crt"), - KeyFile: filepath.Join("testdata", "server.key"), - }, - ClientCAFile: filepath.Join("testdata", "server.crt"), - }, - tlsClientCreds: &configtls.TLSClientSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - CertFile: filepath.Join("testdata", "client.crt"), - KeyFile: filepath.Join("testdata", "client.key"), - }, - ServerName: "localhost", - }, - hasError: true, - }, - } - // prepare - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - hss := &HTTPServerSettings{ - Endpoint: "localhost:0", - TLSSetting: tt.tlsServerCreds, - } - ln, err := hss.ToListener() - require.NoError(t, err) - - s, err := hss.ToServer( - componenttest.NewNopHost(), - componenttest.NewNopTelemetrySettings(), - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, errWrite := fmt.Fprint(w, "test") - assert.NoError(t, errWrite) - })) - require.NoError(t, err) - - go func() { - _ = s.Serve(ln) - }() - - // Wait for the servers to start - <-time.After(10 * time.Millisecond) - - prefix := "https://" - expectedProto := "HTTP/2.0" - if tt.tlsClientCreds.Insecure { - prefix = "http://" - expectedProto = "HTTP/1.1" - } - - hcs := &HTTPClientSettings{ - Endpoint: prefix + ln.Addr().String(), - TLSSetting: *tt.tlsClientCreds, - } - if tt.forceHTTP1 { - expectedProto = "HTTP/1.1" - hcs.CustomRoundTripper = func(rt http.RoundTripper) (http.RoundTripper, error) { - rt.(*http.Transport).ForceAttemptHTTP2 = false - return rt, nil - } - } - client, errClient := hcs.ToClient(componenttest.NewNopHost(), component.TelemetrySettings{}) - require.NoError(t, errClient) - - resp, errResp := client.Get(hcs.Endpoint) - if tt.hasError { - assert.Error(t, errResp) - } else { - assert.NoError(t, errResp) - body, errRead := io.ReadAll(resp.Body) - assert.NoError(t, errRead) - assert.Equal(t, "test", string(body)) - assert.Equal(t, expectedProto, resp.Proto) - } - require.NoError(t, s.Close()) - }) - } -} - -func TestHttpCors(t *testing.T) { - tests := []struct { - name string - - *CORSSettings - - allowedWorks bool - disallowedWorks bool - extraHeaderWorks bool - }{ - { - name: "noCORS", - allowedWorks: false, - disallowedWorks: false, - extraHeaderWorks: false, - }, - { - name: "emptyCORS", - CORSSettings: &CORSSettings{}, - allowedWorks: false, - disallowedWorks: false, - extraHeaderWorks: false, - }, - { - name: "OriginCORS", - CORSSettings: &CORSSettings{ - AllowedOrigins: []string{"allowed-*.com"}, - }, - allowedWorks: true, - disallowedWorks: false, - extraHeaderWorks: false, - }, - { - name: "CacheableCORS", - CORSSettings: &CORSSettings{ - AllowedOrigins: []string{"allowed-*.com"}, - MaxAge: 360, - }, - allowedWorks: true, - disallowedWorks: false, - extraHeaderWorks: false, - }, - { - name: "HeaderCORS", - CORSSettings: &CORSSettings{ - AllowedOrigins: []string{"allowed-*.com"}, - AllowedHeaders: []string{"ExtraHeader"}, - }, - allowedWorks: true, - disallowedWorks: false, - extraHeaderWorks: true, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - hss := &HTTPServerSettings{ - Endpoint: "localhost:0", - CORS: tt.CORSSettings, - } - - ln, err := hss.ToListener() - require.NoError(t, err) - - s, err := hss.ToServer( - componenttest.NewNopHost(), - componenttest.NewNopTelemetrySettings(), - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - })) - require.NoError(t, err) - - go func() { - _ = s.Serve(ln) - }() - - // TODO: make starting server deterministic - // Wait for the servers to start - <-time.After(10 * time.Millisecond) - - url := fmt.Sprintf("http://%s", ln.Addr().String()) - - expectedStatus := http.StatusNoContent - if tt.CORSSettings == nil || len(tt.AllowedOrigins) == 0 { - expectedStatus = http.StatusOK - } - - // Verify allowed domain gets responses that allow CORS. - verifyCorsResp(t, url, "allowed-origin.com", tt.CORSSettings, false, expectedStatus, tt.allowedWorks) - - // Verify allowed domain and extra headers gets responses that allow CORS. - verifyCorsResp(t, url, "allowed-origin.com", tt.CORSSettings, true, expectedStatus, tt.extraHeaderWorks) - - // Verify disallowed domain gets responses that disallow CORS. - verifyCorsResp(t, url, "disallowed-origin.com", tt.CORSSettings, false, expectedStatus, tt.disallowedWorks) - - require.NoError(t, s.Close()) - }) - } -} - -func TestHttpCorsInvalidSettings(t *testing.T) { - hss := &HTTPServerSettings{ - Endpoint: "localhost:0", - CORS: &CORSSettings{AllowedHeaders: []string{"some-header"}}, - } - - // This effectively does not enable CORS but should also not cause an error - s, err := hss.ToServer( - componenttest.NewNopHost(), - componenttest.NewNopTelemetrySettings(), - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) - require.NoError(t, err) - require.NotNil(t, s) - require.NoError(t, s.Close()) -} - -func TestHttpCorsWithSettings(t *testing.T) { - hss := &HTTPServerSettings{ - Endpoint: "localhost:0", - CORS: &CORSSettings{ - AllowedOrigins: []string{"*"}, - }, - Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("mock"), - }, - } - - host := &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("mock"): auth.NewServer( - auth.WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) { - return ctx, errors.New("Settings failed") - }), - ), - }, - } - - srv, err := hss.ToServer(host, componenttest.NewNopTelemetrySettings(), nil) - require.NoError(t, err) - require.NotNil(t, srv) - - rec := httptest.NewRecorder() - req := httptest.NewRequest(http.MethodOptions, "/", nil) - req.Header.Set("Origin", "http://localhost") - req.Header.Set("Access-Control-Request-Method", http.MethodPost) - srv.Handler.ServeHTTP(rec, req) - - assert.Equal(t, http.StatusNoContent, rec.Result().StatusCode) - assert.Equal(t, "*", rec.Header().Get("Access-Control-Allow-Origin")) -} - -func TestHttpServerHeaders(t *testing.T) { - tests := []struct { - name string - headers map[string]configopaque.String - }{ - { - name: "noHeaders", - headers: nil, - }, - { - name: "emptyHeaders", - headers: map[string]configopaque.String{}, - }, - { - name: "withHeaders", - headers: map[string]configopaque.String{ - "x-new-header-1": "value1", - "x-new-header-2": "value2", - }, - }, - } - - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - hss := &HTTPServerSettings{ - Endpoint: "localhost:0", - ResponseHeaders: tt.headers, - } - - ln, err := hss.ToListener() - require.NoError(t, err) - - s, err := hss.ToServer( - componenttest.NewNopHost(), - componenttest.NewNopTelemetrySettings(), - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - w.WriteHeader(http.StatusOK) - })) - require.NoError(t, err) - - go func() { - _ = s.Serve(ln) - }() - - // TODO: make starting server deterministic - // Wait for the servers to start - <-time.After(10 * time.Millisecond) - - url := fmt.Sprintf("http://%s", ln.Addr().String()) - - // Verify allowed domain gets responses that allow CORS. - verifyHeadersResp(t, url, tt.headers) - - require.NoError(t, s.Close()) - }) - } -} - -func verifyCorsResp(t *testing.T, url string, origin string, set *CORSSettings, extraHeader bool, wantStatus int, wantAllowed bool) { - req, err := http.NewRequest(http.MethodOptions, url, nil) - require.NoError(t, err, "Error creating trace OPTIONS request: %v", err) - req.Header.Set("Origin", origin) - if extraHeader { - req.Header.Set("ExtraHeader", "foo") - req.Header.Set("Access-Control-Request-Headers", "ExtraHeader") - } - req.Header.Set("Access-Control-Request-Method", "POST") - - resp, err := http.DefaultClient.Do(req) - require.NoError(t, err, "Error sending OPTIONS to http server: %v", err) - - err = resp.Body.Close() - if err != nil { - t.Errorf("Error closing OPTIONS response body, %v", err) - } - - assert.Equal(t, wantStatus, resp.StatusCode) - - gotAllowOrigin := resp.Header.Get("Access-Control-Allow-Origin") - gotAllowMethods := resp.Header.Get("Access-Control-Allow-Methods") - - wantAllowOrigin := "" - wantAllowMethods := "" - wantMaxAge := "" - if wantAllowed { - wantAllowOrigin = origin - wantAllowMethods = "POST" - if set != nil && set.MaxAge != 0 { - wantMaxAge = fmt.Sprintf("%d", set.MaxAge) - } - } - assert.Equal(t, wantAllowOrigin, gotAllowOrigin) - assert.Equal(t, wantAllowMethods, gotAllowMethods) - assert.Equal(t, wantMaxAge, resp.Header.Get("Access-Control-Max-Age")) -} - -func verifyHeadersResp(t *testing.T, url string, expected map[string]configopaque.String) { - req, err := http.NewRequest(http.MethodGet, url, nil) - require.NoError(t, err, "Error creating request: %v", err) - - resp, err := http.DefaultClient.Do(req) - require.NoError(t, err, "Error sending request to http server: %v", err) - - err = resp.Body.Close() - if err != nil { - t.Errorf("Error closing response body, %v", err) - } - - assert.Equal(t, http.StatusOK, resp.StatusCode) - - for k, v := range expected { - assert.Equal(t, string(v), resp.Header.Get(k)) - } -} - -func ExampleHTTPServerSettings() { - settings := HTTPServerSettings{ - Endpoint: "localhost:443", - } - s, err := settings.ToServer( - componenttest.NewNopHost(), - componenttest.NewNopTelemetrySettings(), - http.HandlerFunc(func(http.ResponseWriter, *http.Request) {})) - if err != nil { - panic(err) - } - - l, err := settings.ToListener() - if err != nil { - panic(err) - } - if err = s.Serve(l); err != nil { - panic(err) - } -} - -func TestHttpClientHeaders(t *testing.T) { - tests := []struct { - name string - headers map[string]configopaque.String - }{ - { - name: "with_headers", - headers: map[string]configopaque.String{ - "header1": "value1", - }, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - for k, v := range tt.headers { - assert.Equal(t, r.Header.Get(k), string(v)) - } - w.WriteHeader(http.StatusOK) - })) - defer server.Close() - serverURL, _ := url.Parse(server.URL) - setting := HTTPClientSettings{ - Endpoint: serverURL.String(), - TLSSetting: configtls.TLSClientSetting{}, - ReadBufferSize: 0, - WriteBufferSize: 0, - Timeout: 0, - Headers: tt.headers, - } - client, _ := setting.ToClient(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings()) - req, err := http.NewRequest(http.MethodGet, setting.Endpoint, nil) - assert.NoError(t, err) - _, err = client.Do(req) - assert.NoError(t, err) - }) - } -} - -func TestContextWithClient(t *testing.T) { - testCases := []struct { - desc string - input *http.Request - doMetadata bool - expected client.Info - }{ - { - desc: "request without client IP or headers", - input: &http.Request{}, - expected: client.Info{}, - }, - { - desc: "request with client IP", - input: &http.Request{ - RemoteAddr: "1.2.3.4:55443", - }, - expected: client.Info{ - Addr: &net.IPAddr{ - IP: net.IPv4(1, 2, 3, 4), - }, - }, - }, - { - desc: "request with client headers, no metadata processing", - input: &http.Request{ - Header: map[string][]string{"x-test-header": {"test-value"}}, - }, - doMetadata: false, - expected: client.Info{}, - }, - { - desc: "request with client headers", - input: &http.Request{ - Header: map[string][]string{"x-test-header": {"test-value"}}, - }, - doMetadata: true, - expected: client.Info{ - Metadata: client.NewMetadata(map[string][]string{"x-test-header": {"test-value"}}), - }, - }, - { - desc: "request with Host and client headers", - input: &http.Request{ - Header: map[string][]string{"x-test-header": {"test-value"}}, - Host: "localhost:55443", - }, - doMetadata: true, - expected: client.Info{ - Metadata: client.NewMetadata(map[string][]string{"x-test-header": {"test-value"}, "Host": {"localhost:55443"}}), - }, - }, - } - for _, tC := range testCases { - t.Run(tC.desc, func(t *testing.T) { - ctx := contextWithClient(tC.input, tC.doMetadata) - assert.Equal(t, tC.expected, client.FromContext(ctx)) - }) - } -} - -func TestServerAuth(t *testing.T) { - // prepare - authCalled := false - hss := HTTPServerSettings{ - Endpoint: "localhost:0", - Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("mock"), - }, - } - - host := &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("mock"): auth.NewServer( - auth.WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) { - authCalled = true - return ctx, nil - }), - ), - }, - } - - handlerCalled := false - handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - handlerCalled = true - }) - - srv, err := hss.ToServer(host, componenttest.NewNopTelemetrySettings(), handler) - require.NoError(t, err) - - // test - srv.Handler.ServeHTTP(&httptest.ResponseRecorder{}, httptest.NewRequest("GET", "/", nil)) - - // verify - assert.True(t, handlerCalled) - assert.True(t, authCalled) -} - -func TestInvalidServerAuth(t *testing.T) { - hss := HTTPServerSettings{ - Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("non-existing"), - }, - } - - srv, err := hss.ToServer(componenttest.NewNopHost(), componenttest.NewNopTelemetrySettings(), http.NewServeMux()) - require.Error(t, err) - require.Nil(t, srv) -} - -func TestFailedServerAuth(t *testing.T) { - // prepare - hss := HTTPServerSettings{ - Endpoint: "localhost:0", - Auth: &configauth.Authentication{ - AuthenticatorID: component.NewID("mock"), - }, - } - host := &mockHost{ - ext: map[component.ID]component.Component{ - component.NewID("mock"): auth.NewServer( - auth.WithServerAuthenticate(func(ctx context.Context, headers map[string][]string) (context.Context, error) { - return ctx, errors.New("Settings failed") - }), - ), - }, - } - - srv, err := hss.ToServer(host, componenttest.NewNopTelemetrySettings(), http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})) - require.NoError(t, err) - - // test - response := &httptest.ResponseRecorder{} - srv.Handler.ServeHTTP(response, httptest.NewRequest("GET", "/", nil)) - - // verify - assert.Equal(t, response.Result().StatusCode, http.StatusUnauthorized) - assert.Equal(t, response.Result().Status, fmt.Sprintf("%v %s", http.StatusUnauthorized, http.StatusText(http.StatusUnauthorized))) -} - -func TestServerWithErrorHandler(t *testing.T) { - // prepare - hss := HTTPServerSettings{ - Endpoint: "localhost:0", - } - eh := func(w http.ResponseWriter, r *http.Request, errorMsg string, statusCode int) { - assert.Equal(t, statusCode, http.StatusBadRequest) - // custom error handler changes returned status code - http.Error(w, "invalid request", http.StatusInternalServerError) - - } - - srv, err := hss.ToServer( - componenttest.NewNopHost(), - componenttest.NewNopTelemetrySettings(), - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}), - WithErrorHandler(eh), - ) - require.NoError(t, err) - // test - response := &httptest.ResponseRecorder{} - - req, err := http.NewRequest(http.MethodGet, srv.Addr, nil) - require.NoError(t, err, "Error creating request: %v", err) - req.Header.Set("Content-Encoding", "something-invalid") - - srv.Handler.ServeHTTP(response, req) - // verify - assert.Equal(t, response.Result().StatusCode, http.StatusInternalServerError) -} - -func TestServerWithDecoder(t *testing.T) { - // prepare - hss := HTTPServerSettings{ - Endpoint: "localhost:0", - } - decoder := func(body io.ReadCloser) (io.ReadCloser, error) { - return body, nil - } - - srv, err := hss.ToServer( - componenttest.NewNopHost(), - componenttest.NewNopTelemetrySettings(), - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {}), - WithDecoder("something-else", decoder), - ) - require.NoError(t, err) - // test - response := &httptest.ResponseRecorder{} - - req, err := http.NewRequest(http.MethodGet, srv.Addr, nil) - require.NoError(t, err, "Error creating request: %v", err) - req.Header.Set("Content-Encoding", "something-else") - - srv.Handler.ServeHTTP(response, req) - // verify - assert.Equal(t, response.Result().StatusCode, http.StatusOK) - -} - -type mockHost struct { - component.Host - ext map[component.ID]component.Component -} - -func (nh *mockHost) GetExtensions() map[component.ID]component.Component { - return nh.ext -} - -func BenchmarkHttpRequest(b *testing.B) { - tests := []struct { - name string - forceHTTP1 bool - clientPerThread bool - }{ - { - name: "HTTP/2.0, shared client (like load balancer)", - forceHTTP1: false, - clientPerThread: false, - }, - { - name: "HTTP/1.1, shared client (like load balancer)", - forceHTTP1: true, - clientPerThread: false, - }, - { - name: "HTTP/2.0, client per thread (like single app)", - forceHTTP1: false, - clientPerThread: true, - }, - { - name: "HTTP/1.1, client per thread (like single app)", - forceHTTP1: true, - clientPerThread: true, - }, - } - - tlsServerCreds := &configtls.TLSServerSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - CertFile: filepath.Join("testdata", "server.crt"), - KeyFile: filepath.Join("testdata", "server.key"), - }, - } - tlsClientCreds := &configtls.TLSClientSetting{ - TLSSetting: configtls.TLSSetting{ - CAFile: filepath.Join("testdata", "ca.crt"), - }, - ServerName: "localhost", - } - - hss := &HTTPServerSettings{ - Endpoint: "localhost:0", - TLSSetting: tlsServerCreds, - } - - s, err := hss.ToServer( - componenttest.NewNopHost(), - componenttest.NewNopTelemetrySettings(), - http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - _, errWrite := fmt.Fprint(w, "test") - require.NoError(b, errWrite) - })) - require.NoError(b, err) - ln, err := hss.ToListener() - require.NoError(b, err) - - go func() { - _ = s.Serve(ln) - }() - defer func() { - _ = s.Close() - }() - - // Wait for the servers to start - <-time.After(10 * time.Millisecond) - - for _, bb := range tests { - hcs := &HTTPClientSettings{ - Endpoint: "https://" + ln.Addr().String(), - TLSSetting: *tlsClientCreds, - } - if bb.forceHTTP1 { - hcs.CustomRoundTripper = func(rt http.RoundTripper) (http.RoundTripper, error) { - rt.(*http.Transport).ForceAttemptHTTP2 = false - return rt, nil - } - } - b.Run(bb.name, func(b *testing.B) { - var c *http.Client - if !bb.clientPerThread { - c, err = hcs.ToClient(componenttest.NewNopHost(), component.TelemetrySettings{}) - require.NoError(b, err) - } - b.RunParallel(func(pb *testing.PB) { - if c == nil { - c, err = hcs.ToClient(componenttest.NewNopHost(), component.TelemetrySettings{}) - require.NoError(b, err) - } - for pb.Next() { - resp, errResp := c.Get(hcs.Endpoint) - require.NoError(b, errResp) - body, errRead := io.ReadAll(resp.Body) - _ = resp.Body.Close() - require.NoError(b, errRead) - require.Equal(b, "test", string(body)) - } - c.CloseIdleConnections() - }) - // Wait for connections to close before closing server to prevent log spam - <-time.After(10 * time.Millisecond) - }) - } -} diff --git a/config/confighttp/doc.go b/config/confighttp/doc.go deleted file mode 100644 index 2813862672ec..000000000000 --- a/config/confighttp/doc.go +++ /dev/null @@ -1,6 +0,0 @@ -// Copyright The OpenTelemetry Authors -// SPDX-License-Identifier: Apache-2.0 - -// Package confighttp defines the configuration settings -// for creating an HTTP client and server. -package confighttp // import "go.opentelemetry.io/collector/config/confighttp" diff --git a/config/confighttp/go.mod b/config/confighttp/go.mod deleted file mode 100644 index 23d4d5b84522..000000000000 --- a/config/confighttp/go.mod +++ /dev/null @@ -1,54 +0,0 @@ -module go.opentelemetry.io/collector/config/confighttp - -go 1.20 - -require ( - github.com/golang/snappy v0.0.4 - github.com/klauspost/compress v1.17.2 - github.com/rs/cors v1.10.1 - github.com/stretchr/testify v1.8.4 - go.opentelemetry.io/collector v0.89.0 - go.opentelemetry.io/collector/component v0.89.0 - go.opentelemetry.io/collector/config/configauth v0.89.0 - go.opentelemetry.io/collector/config/configcompression v0.89.0 - go.opentelemetry.io/collector/config/configopaque v0.89.0 - go.opentelemetry.io/collector/config/configtelemetry v0.89.0 - go.opentelemetry.io/collector/config/configtls v0.89.0 - go.opentelemetry.io/collector/config/internal v0.89.0 - go.opentelemetry.io/collector/extension/auth v0.89.0 - go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.0 - go.opentelemetry.io/otel v1.20.0 - go.uber.org/zap v1.26.0 - golang.org/x/net v0.17.0 -) - -require ( - github.com/davecgh/go-spew v1.1.1 // indirect - github.com/felixge/httpsnoop v1.0.4 // indirect - github.com/fsnotify/fsnotify v1.7.0 // indirect - github.com/go-logr/logr v1.3.0 // indirect - github.com/go-logr/stdr v1.2.2 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect - github.com/hashicorp/go-version v1.6.0 // indirect - github.com/knadh/koanf/maps v0.1.1 // indirect - github.com/knadh/koanf/providers/confmap v0.1.0 // indirect - github.com/knadh/koanf/v2 v2.0.1 // indirect - github.com/mitchellh/copystructure v1.2.0 // indirect - github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 // indirect - github.com/mitchellh/reflectwalk v1.0.2 // indirect - github.com/pmezard/go-difflib v1.0.0 // indirect - go.opentelemetry.io/collector/confmap v0.89.0 // indirect - go.opentelemetry.io/collector/extension v0.89.0 // indirect - go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 // indirect - go.opentelemetry.io/collector/pdata v1.0.0-rcv0018 // indirect - go.opentelemetry.io/otel/metric v1.20.0 // indirect - go.opentelemetry.io/otel/trace v1.20.0 // indirect - go.uber.org/multierr v1.11.0 // indirect - golang.org/x/sys v0.14.0 // indirect - golang.org/x/text v0.13.0 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect - google.golang.org/grpc v1.59.0 // indirect - google.golang.org/protobuf v1.31.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect -) diff --git a/config/confighttp/go.sum b/config/confighttp/go.sum deleted file mode 100644 index bf9456a7ab0d..000000000000 --- a/config/confighttp/go.sum +++ /dev/null @@ -1,135 +0,0 @@ -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg= -github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U= -github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= -github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.3.0 h1:2y3SDp0ZXuc6/cjLSZ+Q3ir+QB9T/iG5yYRXqsagWSY= -github.com/go-logr/logr v1.3.0/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM= -github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/hashicorp/go-version v1.6.0 h1:feTTfFNnjP967rlCxM/I9g701jU+RN74YKx2mOkIeek= -github.com/hashicorp/go-version v1.6.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.2 h1:RlWWUY/Dr4fL8qk9YG7DTZ7PDgME2V4csBXA8L/ixi4= -github.com/klauspost/compress v1.17.2/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= -github.com/knadh/koanf/maps v0.1.1 h1:G5TjmUh2D7G2YWf5SQQqSiHRJEjaicvU0KpypqB3NIs= -github.com/knadh/koanf/maps v0.1.1/go.mod h1:npD/QZY3V6ghQDdcQzl1W4ICNVTkohC8E73eI2xW4yI= -github.com/knadh/koanf/providers/confmap v0.1.0 h1:gOkxhHkemwG4LezxxN8DMOFopOPghxRVp7JbIvdvqzU= -github.com/knadh/koanf/providers/confmap v0.1.0/go.mod h1:2uLhxQzJnyHKfxG927awZC7+fyHFdQkd697K4MdLnIU= -github.com/knadh/koanf/v2 v2.0.1 h1:1dYGITt1I23x8cfx8ZnldtezdyaZtfAuRtIFOiRzK7g= -github.com/knadh/koanf/v2 v2.0.1/go.mod h1:ZeiIlIDXTE7w1lMT6UVcNiRAS2/rCeLn/GdLNvY1Dus= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw= -github.com/mitchellh/copystructure v1.2.0/go.mod h1:qLl+cE2AmVv+CoeAwDPye/v+N2HKCj9FbZEVFJRxO9s= -github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4 h1:BpfhmLKZf+SjVanKKhCgf3bg+511DmU9eDQTen7LLbY= -github.com/mitchellh/mapstructure v1.5.1-0.20220423185008-bf980b35cac4/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zxSIeXaQ= -github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rs/cors v1.10.1 h1:L0uuZVXIKlI1SShY2nhFfo44TYvDPQ1w4oFkUJNfhyo= -github.com/rs/cors v1.10.1/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.opentelemetry.io/collector v0.89.0 h1:lzpfD9NTHh+1M+qzcoYUH+i2rOgFSox3bGQFUI5BPJg= -go.opentelemetry.io/collector v0.89.0/go.mod h1:UZUtmQ3kai0CLPWvPmHKpmwqqEoo50n1bwzYYhXX0eA= -go.opentelemetry.io/collector/component v0.89.0 h1:PoQJX86BpaSZhzx0deQXHh3QMuW6XKVmolSdTKE506c= -go.opentelemetry.io/collector/component v0.89.0/go.mod h1:ZZncnMVaNs++JIbAMiemUIWLZrZ3PMEzI3S3K8pnkws= -go.opentelemetry.io/collector/config/configauth v0.89.0 h1:F082cy1OwrjyucI0wgEO2lRPTWJlgJzM/I5d0BoVgp4= -go.opentelemetry.io/collector/config/configauth v0.89.0/go.mod h1:yRJj70B3MyfbyGuyKO1I+5LtGuvx/WLUh8kuQ/XX6RE= -go.opentelemetry.io/collector/config/configcompression v0.89.0 h1:Z4LG045HwoNqXaibVbAQkcAQGmvY4OHrY4eCppoAzoQ= -go.opentelemetry.io/collector/config/configcompression v0.89.0/go.mod h1:LaavoxZsro5lL7qh1g9DMifG0qixWPEecW18Qr8bpag= -go.opentelemetry.io/collector/config/configopaque v0.89.0 h1:Ad6yGcGBHs+J9SNjkedY68JsLZ1vBn4kKzdqKuTCRsE= -go.opentelemetry.io/collector/config/configopaque v0.89.0/go.mod h1:TPCHaU+QXiEV+JXbgyr6mSErTI9chwQyasDVMdJr3eY= -go.opentelemetry.io/collector/config/configtelemetry v0.89.0 h1:NtRknYDfMgP1r8mnByo6qQQK8IBw/lF9Qke5f7VhGZ0= -go.opentelemetry.io/collector/config/configtelemetry v0.89.0/go.mod h1:+LAXM5WFMW/UbTlAuSs6L/W72WC+q8TBJt/6z39FPOU= -go.opentelemetry.io/collector/config/configtls v0.89.0 h1:XDeUaTU7LYwnEXz/CSdjbCStJa7n0YR1q0QpK0Vtw9w= -go.opentelemetry.io/collector/config/configtls v0.89.0/go.mod h1:NlE4elqXoyFfzQvYfzgH6uOU1zNVa+5tt6EIq52TJ9Y= -go.opentelemetry.io/collector/config/internal v0.89.0 h1:fs7LJTJd1EF76pjK7ZZZMWNxze0+pDXq3mfRwhm0P0g= -go.opentelemetry.io/collector/config/internal v0.89.0/go.mod h1:42VsQ/1kP2qnvzjNi+dfNP+KyCFRADejyrJ8m2GVL3M= -go.opentelemetry.io/collector/confmap v0.89.0 h1:N5Vg1+FXEFBHHlGIPg4OSlM9uTHjCI7RlWWrKjtOzWQ= -go.opentelemetry.io/collector/confmap v0.89.0/go.mod h1:D8FMPvuihtVxwXaz/qp5q9X2lq9l97QyjfsdZD1spmc= -go.opentelemetry.io/collector/consumer v0.89.0 h1:MteKhkudX2L1ylbtdpSazO8SwyHSxl6fUEElc0rRLDQ= -go.opentelemetry.io/collector/extension v0.89.0 h1:iiaWIPPFqP4T0FSgl6+D1xRUhVnhsk88uk2BxCFqt7E= -go.opentelemetry.io/collector/extension v0.89.0/go.mod h1:tBh5wD4AZ3xFO6M1CjkEEx2urexTqcAcgi9cJSPME3E= -go.opentelemetry.io/collector/extension/auth v0.89.0 h1:eo9JoWklZdSManEPLm1LqlwEq5v/YIsOupjZHdRYm3I= -go.opentelemetry.io/collector/extension/auth v0.89.0/go.mod h1:TzC5WYGMgsZvkpYSU1Jlwxh46tSDmWRLFsc9awXaedk= -go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018 h1:iK4muX3KIMqKk0xwKcRzu4ravgCtUdzsvuxxdz6A27g= -go.opentelemetry.io/collector/featuregate v1.0.0-rcv0018/go.mod h1:xGbRuw+GbutRtVVSEy3YR2yuOlEyiUMhN2M9DJljgqY= -go.opentelemetry.io/collector/pdata v1.0.0-rcv0018 h1:a2IHOZKphRzPagcvOHQHHUE0DlITFSKlIBwaWhPZpl4= -go.opentelemetry.io/collector/pdata v1.0.0-rcv0018/go.mod h1:oNIcTRyEJYIfMcRYyyh5lquDU0Vl+ktTL6ka+p+dYvg= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.0 h1:1eHu3/pUSWaOgltNK3WJFaywKsTIr/PwvHyDmi0lQA0= -go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.46.0/go.mod h1:HyABWq60Uy1kjJSa2BVOxUVao8Cdick5AWSKPutqy6U= -go.opentelemetry.io/otel v1.20.0 h1:vsb/ggIY+hUjD/zCAQHpzTmndPqv/ml2ArbsbfBYTAc= -go.opentelemetry.io/otel v1.20.0/go.mod h1:oUIGj3D77RwJdM6PPZImDpSZGDvkD9fhesHny69JFrs= -go.opentelemetry.io/otel/metric v1.20.0 h1:ZlrO8Hu9+GAhnepmRGhSU7/VkpjrNowxRN9GyKR4wzA= -go.opentelemetry.io/otel/metric v1.20.0/go.mod h1:90DRw3nfK4D7Sm/75yQ00gTJxtkBxX+wu6YaNymbpVM= -go.opentelemetry.io/otel/trace v1.20.0 h1:+yxVAPZPbQhbC3OfAkeIVTky6iTFpcr4SiY9om7mXSQ= -go.opentelemetry.io/otel/trace v1.20.0/go.mod h1:HJSK7F/hA5RlzpZ0zKDCHCDHm556LCDtKaAo6JmBFUU= -go.uber.org/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A= -go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= -go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM= -golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.14.0 h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q= -golang.org/x/sys v0.14.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k= -golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= -google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= -google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= -google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/config/confighttp/testdata/ca.crt b/config/confighttp/testdata/ca.crt deleted file mode 100644 index e850c66f4f78..000000000000 --- a/config/confighttp/testdata/ca.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDNjCCAh4CCQCBqDI24JacNTANBgkqhkiG9w0BAQsFADBdMQswCQYDVQQGEwJB -VTESMBAGA1UECAwJQXVzdHJhbGlhMQ8wDQYDVQQHDAZTeWRuZXkxEjAQBgNVBAoM -CU15T3JnTmFtZTEVMBMGA1UEAwwMTXlDb21tb25OYW1lMB4XDTIyMDgwMzA0MTAx -N1oXDTMyMDczMTA0MTAxN1owXTELMAkGA1UEBhMCQVUxEjAQBgNVBAgMCUF1c3Ry -YWxpYTEPMA0GA1UEBwwGU3lkbmV5MRIwEAYDVQQKDAlNeU9yZ05hbWUxFTATBgNV -BAMMDE15Q29tbW9uTmFtZTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB -ANFDGZCSxNdaJQ1q7P5qVAZDKCj+3ClpFWAVT5HYDlOqgIjYRZ45/YGfKsDbK6rj -/+v5xTnTZt8e8kRfPgrZTBtPtefu6tKwxYYr3sSCR3TU4bX4dIM9ZwrFaTrPP1hk -UXR8zlk7F6gcWS+WX7LdupMs5SdZIePhkzpkxYIBatdRMf7w2f5v6M3UnOrCoyz0 -YPvvyZKq5zo9uBlVkrUL/QDrOB5yYjith7l8FkLHAirGTaszfF+8pZwzZn4ykVbn -eQQs1g6ujR0DgQh/k6A6XDQfg4JWQqNt3kkiO7NPIHTrl+W/nKdqve864ECAHSM2 -NIgGtQqVavPKD6pr15V328cCAwEAATANBgkqhkiG9w0BAQsFAAOCAQEALZuCeu8U -yjJlR+BbDqiZw7/EBpGgTX4mv9CofJc9ErxFGJTYiaLZ1Jf3bwE+0G9ym8UfxKG8 -9xCYmoVbEQhgLzYDpYPxkKi5X7RUMw9fKlbRqwy2Ek1mDnSIYPRalhfOXBT5E652 -OUeILLRJlAPL3SrALjJM5Jjn4pkwankE53mfU4LpC7xWOjuwkSPRor1XCwoAZMTz -EZsZGUQf5M69ZAy0wWHu4C94rlgD37hybUEzhsr9UiK2v1Gn3a7BSAgtkbD0OIe5 -BzCu+UHQO4u841SbXn4q8aO1idaR8UhPAqfVno+L7ZmHRGsgvMk1vlMbroIIYaAz -2LQP6IwYUWRM9Q== ------END CERTIFICATE----- diff --git a/config/confighttp/testdata/client.crt b/config/confighttp/testdata/client.crt deleted file mode 100644 index 375ffd32a246..000000000000 --- a/config/confighttp/testdata/client.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDVTCCAj2gAwIBAgIJANt5fkUlfxyOMA0GCSqGSIb3DQEBCwUAMF0xCzAJBgNV -BAYTAkFVMRIwEAYDVQQIDAlBdXN0cmFsaWExDzANBgNVBAcMBlN5ZG5leTESMBAG -A1UECgwJTXlPcmdOYW1lMRUwEwYDVQQDDAxNeUNvbW1vbk5hbWUwHhcNMjIwODAz -MDQxMDE3WhcNMzIwNzMxMDQxMDE3WjBdMQswCQYDVQQGEwJBVTESMBAGA1UECAwJ -QXVzdHJhbGlhMQ8wDQYDVQQHDAZTeWRuZXkxEjAQBgNVBAoMCU15T3JnTmFtZTEV -MBMGA1UEAwwMTXlDb21tb25OYW1lMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEApmnIUees+b/V5gEgEOwyjPo9xeejzd/DSo02x/syauoU4mhINwa8cuB+ -nvGhCUY5w+bZfOnWhY03wjnqM1Ay+sg7yHZgqeHclzQh5d39ojeaMa3x8c3IQsKZ -j/UTyYmkX6Gap8Z8fk1ucM43clM3nUUf3THzeo0X3MTm7FIs2OCxcbCYo8GUo6GV -rn7nhutOrYgyPrgo7bi8xF2sJRRKC/C7MBCeNaJlgj53jB93gF15/ZxPbAQCtI5R -J+3YrKp987RSuXtDeqm1zSCmV6LnT2vVsSNmnDdvWHQF7SqgauqT0Z7gm4/M/xXw -ge6GJaENOV1wIUsfbYj6UCMt6tZpjQIDAQABoxgwFjAUBgNVHREEDTALgglsb2Nh -bGhvc3QwDQYJKoZIhvcNAQELBQADggEBAHwMOQIz++7JPWRb3xHTkt6jIlAw/zVl -3UmdXMqEEscLGcjmDqu0u1qPGlS48Ukb4efAQsp+/2KLQex7jdl3r4p0+3O530AY -MEtlK2oH1uE3KDMyswA0INrGeZpHRP2BI6QJGbxcJN22MuHFmKwPBJlltgVtK0Gt -IhG/cRJnVMcX+iBdsxygW5u7P8MpC8Eoved/F8yKB66uJ4LyZC5KL9RG58Y0JJin -KDvpzSGLMnHgnuJlGOGz/uUYXZ4IX5g95yKiDZ9+GkVo+DRHAUNEUjfQSRujmO10 -INTHs4/hd0MI6NaHXwObvmOsa8VRRVWa995O5Y9rZMYg/4mjm1Axcm4= ------END CERTIFICATE----- diff --git a/config/confighttp/testdata/client.key b/config/confighttp/testdata/client.key deleted file mode 100644 index e15ea84e6821..000000000000 --- a/config/confighttp/testdata/client.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpAIBAAKCAQEApmnIUees+b/V5gEgEOwyjPo9xeejzd/DSo02x/syauoU4mhI -Nwa8cuB+nvGhCUY5w+bZfOnWhY03wjnqM1Ay+sg7yHZgqeHclzQh5d39ojeaMa3x -8c3IQsKZj/UTyYmkX6Gap8Z8fk1ucM43clM3nUUf3THzeo0X3MTm7FIs2OCxcbCY -o8GUo6GVrn7nhutOrYgyPrgo7bi8xF2sJRRKC/C7MBCeNaJlgj53jB93gF15/ZxP -bAQCtI5RJ+3YrKp987RSuXtDeqm1zSCmV6LnT2vVsSNmnDdvWHQF7SqgauqT0Z7g -m4/M/xXwge6GJaENOV1wIUsfbYj6UCMt6tZpjQIDAQABAoIBAEAIGfUyAMPEhchP -jIgWakkGjLhWrhesTtejyH1gcYDj+w828vqBVAeby/zamo0YAWgYrny6+TlAIkFQ -yYXfCQ6n9yDmM8GKT7e6boSlS0+ct28AMEVLWhAeErpqoad9l8rYQsrlu8dZgfJT -1s/dp1uTWnRhIP95xMHE3dn2sJzuEV9HunkgS6re6YyTqNZFLAPVn33wDRVSaxH6 -3VJG6T3Y2xs77AKTKz5Mji/gqK3XFAed0rehowgS4A8mEUrZt9gzioRlmV2tshvx -st5KDw7lGEZKbgGB/+cwLJhHgEK7KyJRsR/shtDyXKRlEC19qV6zSupz9BSQNqRN -+vWQ070CgYEA0NTYgdxz8msVMXtLCectwMLfLU99H/frGCvjBv0wLni2XF+eS9gX -D6W4nFbDA+wZfSBMpEqriHvrDpMk7RN3Q9rAKtqeyzDboWiJRRT4DZeRz9o+WEt3 -+wDP8W0dS7IRw8Jnrsj9JgmY35fGXZDUWZRnPuvrpolojUnMTKNK/ccCgYEAzAA1 -roKRNOn08P3SZ0jCUA0O+Ke5sycV6QPoLk5qQnL5eEjOlvd+6U128DAf1DW5O6/8 -C0YsTMOY/sQxXliSt/iygaJVoo7Tt1L60ctNY4KX5EiWs2AgvvTu89ESwbhvvfvw -Xt7PNfa0eBSgC+Lrg5y2Lahs8DijWkTbxo3ebgsCgYEAmyLjzGUnRZnDXsUHE85H -sQGTpid8/rjAT26a82A34O4QG0N1Z0aaqycjpBDYQxusO8Y46XwHPhdAoc0yC2UA -nsntJGjQuoYLQzdTcpyHQiGtUsoAsrst4KvTzriOoOMiS1kqiTAKz60lgkVQOcYT -2pBiut2sbEV8BCokuXI9jZUCgYBbg9yRJNGvQyU21ycEXoeNEc6djeColegmWDJY -U6Unmhx/8Wl8IBs23iF1LqGYuWEXfaM8C4bkCPshjzH2eRWYomCx9vkjq58epoMO -in11Hqi1KDsyzPTjtU1c43Xeoba/K75xUNL0CnB7TgVeT7YHnM29PclhGodtf2Z4 -dDxMcQKBgQC46rtyosn/2uR+88DCWSVTnc4cA6tOEB8WP7Z7mk8yOv1CGgyP4187 -iDPL+91O4C5sT02MFuwElCmxuO1RQQhVTGzIxPd9RQ7t+l1PorTeodYF/ezrRl47 -xuxp4nF50ThlTf1AuhQxpPC1JsXqkH3d582ZLErzrgijMYxk5sYJRA== ------END RSA PRIVATE KEY----- diff --git a/config/confighttp/testdata/server.crt b/config/confighttp/testdata/server.crt deleted file mode 100644 index cc48c740762b..000000000000 --- a/config/confighttp/testdata/server.crt +++ /dev/null @@ -1,20 +0,0 @@ ------BEGIN CERTIFICATE----- -MIIDVTCCAj2gAwIBAgIJANt5fkUlfxyNMA0GCSqGSIb3DQEBCwUAMF0xCzAJBgNV -BAYTAkFVMRIwEAYDVQQIDAlBdXN0cmFsaWExDzANBgNVBAcMBlN5ZG5leTESMBAG -A1UECgwJTXlPcmdOYW1lMRUwEwYDVQQDDAxNeUNvbW1vbk5hbWUwHhcNMjIwODAz -MDQxMDE3WhcNMzIwNzMxMDQxMDE3WjBdMQswCQYDVQQGEwJBVTESMBAGA1UECAwJ -QXVzdHJhbGlhMQ8wDQYDVQQHDAZTeWRuZXkxEjAQBgNVBAoMCU15T3JnTmFtZTEV -MBMGA1UEAwwMTXlDb21tb25OYW1lMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB -CgKCAQEAupEXxNIX+2k0PC/yLfuWSbFr22eLwYSYkPDydFENKYID905hcWqaqr4o -u1Fu8nofbeKrpTgmx7lwXB5VIkdNcnwLyt40nPETGN2m0vBa7Bm6z/KJTW0iHmTz -5fVzt9rggnRTRSovNy43weKoZXHcl/lmGbGy+lqQ69jJTT9yXipkMTIkscYgSHK3 -GVxUhrsBc/mZyBLSj3Tpt3Az71N4npTp6XYbgx4MhllbH9xFlw2hLs1DU+vwJhSE -w99UrLhRz8L3ePmShdkySD9QZxCKD5euiumVfPLfzWV2JmLejC3MD3sd5ql+5itv -WrnYPcky3OclXcnZgDo+ZloWLYPWhQIDAQABoxgwFjAUBgNVHREEDTALgglsb2Nh -bGhvc3QwDQYJKoZIhvcNAQELBQADggEBAJGfixdI6T6dxb37fJPNa0Uerq5aZPb9 -GLJg3CqkZ4yjfsveZ91lH7fRPRjXld3aMb6978kpoczGYJeAdY8j0BPvA+UfsuYO -bzm6HUgiTjyCnLPQIuAlzuYDsBQhzz6gdRclgnuQ8JO/xTDIxVLJDuueannqEn9x -s/RQ5PeWf0D+zvSu4p8UENKfaPqoI5q7nb93IHL38PMDfB7n4oEDIkG0zfxX/zYI -h5ZhzlWSscfCRE4Hdcb8RcSuzwI2JzidMY/ZXUr20iNuCSbv4zhsoDASk7Ud+yj4 -d4JkdOA4NbaT8/aR+Ectc2ItBc2lb0xzEqQnjg3zRQjEzeryHN0hxWU= ------END CERTIFICATE----- diff --git a/config/confighttp/testdata/server.key b/config/confighttp/testdata/server.key deleted file mode 100644 index 16818a165995..000000000000 --- a/config/confighttp/testdata/server.key +++ /dev/null @@ -1,27 +0,0 @@ ------BEGIN RSA PRIVATE KEY----- -MIIEpQIBAAKCAQEAupEXxNIX+2k0PC/yLfuWSbFr22eLwYSYkPDydFENKYID905h -cWqaqr4ou1Fu8nofbeKrpTgmx7lwXB5VIkdNcnwLyt40nPETGN2m0vBa7Bm6z/KJ -TW0iHmTz5fVzt9rggnRTRSovNy43weKoZXHcl/lmGbGy+lqQ69jJTT9yXipkMTIk -scYgSHK3GVxUhrsBc/mZyBLSj3Tpt3Az71N4npTp6XYbgx4MhllbH9xFlw2hLs1D -U+vwJhSEw99UrLhRz8L3ePmShdkySD9QZxCKD5euiumVfPLfzWV2JmLejC3MD3sd -5ql+5itvWrnYPcky3OclXcnZgDo+ZloWLYPWhQIDAQABAoIBAF8u/01vUsT126yJ -WamUHgzi9AAwR+EnYR8xjsFBSNHQf22BE73lgZtzARzwYwZawAY0CxZ0G3TyaxzU -bOLcNese1nVeAMHBTNj23NHpxrmGNwU43EwgTbPsFXNRUwSOKtTjvEghSY2Bivjk -Rr3a5YyztR+OxZ1s71skcy9yG0tmveGRQS2Gn3SrLgrX7PjgUULpd7TNkWlAyTB7 -sFvVeHVEv8AcFDvHCBvlNJvMG2WT7kD4vjbRc0V1y89D4wO3kNVumajNjiSUopsU -zFe1vegcSLIgf1i2QEtXLob6mrQJplDA3G8oQX4FF0Oovk/bLwzC6IHNeFOo5eFM -TfGzd9ECgYEA6Ixx+2Bai2zdSz19NVaQEksDVdT/ivorgYGpIllLOwjU3ZCIEs2J -iNNPlIX9uFcwIGcfoHsU66iUWrwprfnbloezq5aPdHuhW2PE+JUEBqzmQDy+ax/i -HI2IaD42+OJY5RdRfS7cvczIFrW9XECCTkhr08CxZTO7W7VCP0OnpPMCgYEAzWGQ -hHgpyj5kfco/KlRrK6bQBkhbqWkbkoZohVL6hJ2UxC/NBFS3fWYQ2LFyFPBdu+lI -RXkDxroCQJfWGNAe4PlbKcWh5Q9Ps/s8wl0DIR/KM2yhzE2GqfDC6pQ3xFpizbcm -jl+AL2U6Y9Et1nvPjZKo6STf5yrEdIuHgaq61KcCgYEA4g/tmf2/53vr4AGlXx2I -LpBHbMADrzmk41+FaMO/M2NRcxXWgdjW03EAEpTy4am4Ojelch9UZgZaOZ5jMiIL -Slke2zYgvI6WfD4Ps8tAv7CCoH2sanzzFOitaxDX5bg7zHCPog7VPZj+Bb2kmDKJ -ucoDMDVI/eV9RBh/jvqY1OsCgYEAx5iYxVSucGFgcis6Zd3y5VJRermZczO12xmK -vH9e/cDTUjKOUTYvuMuXdbBFiXnr7nIRjYrFE72z8KhfJnAkgklzwk3SP3U45VY1 -v0J7hxaJAJ8DQzTYuZFFLIptBAM/YGMtMlI3llgPffBNVtOuawzr4OC4RMV4dTcg -svCEb6MCgYEAnRx87p5bAgDVug3pdFI7qRi5Tgxa25c5GsFwhmmr3EgtxKQKLFIH -G6KOWJBpFePVrz3PH71d+J1mB/g8GqzpHBuYTBDD3hyz8iKHN+pmoM4m2/tTqKRY -26XUGOUIxnksgsw2O2R9AASrEm4hhAg5AxmANgqOIZijIcHWF8q9QpE= ------END RSA PRIVATE KEY----- diff --git a/processor/resourcedetectionprocessor/go.mod b/processor/resourcedetectionprocessor/go.mod index 78d80523d712..c30968eb5b75 100644 --- a/processor/resourcedetectionprocessor/go.mod +++ b/processor/resourcedetectionprocessor/go.mod @@ -152,6 +152,3 @@ replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/k8sco replace github.com/openshift/api v3.9.0+incompatible => github.com/openshift/api v0.0.0-20180801171038-322a19404e37 replace github.com/amazon-contributing/opentelemetry-collector-contrib/override/aws => ../../override/aws - -// see https://github.com/amazon-contributing/opentelemetry-collector-contrib/pull/99 -replace go.opentelemetry.io/collector/config/confighttp => ../../config/confighttp diff --git a/processor/resourcedetectionprocessor/go.sum b/processor/resourcedetectionprocessor/go.sum index 4e58e8a979f3..2c807732c897 100644 --- a/processor/resourcedetectionprocessor/go.sum +++ b/processor/resourcedetectionprocessor/go.sum @@ -458,6 +458,8 @@ go.opentelemetry.io/collector/config/configauth v0.89.0 h1:F082cy1OwrjyucI0wgEO2 go.opentelemetry.io/collector/config/configauth v0.89.0/go.mod h1:yRJj70B3MyfbyGuyKO1I+5LtGuvx/WLUh8kuQ/XX6RE= go.opentelemetry.io/collector/config/configcompression v0.89.0 h1:Z4LG045HwoNqXaibVbAQkcAQGmvY4OHrY4eCppoAzoQ= go.opentelemetry.io/collector/config/configcompression v0.89.0/go.mod h1:LaavoxZsro5lL7qh1g9DMifG0qixWPEecW18Qr8bpag= +go.opentelemetry.io/collector/config/confighttp v0.89.0 h1:RatLdeZkCu3uLtCjbS8g5Aec2JB3/CSpB6O7P081Bhg= +go.opentelemetry.io/collector/config/confighttp v0.89.0/go.mod h1:R5BIbvqlxSDQGpCRWd2HBZIWijfSIWRpLeSpZjkKkag= go.opentelemetry.io/collector/config/configopaque v0.89.0 h1:Ad6yGcGBHs+J9SNjkedY68JsLZ1vBn4kKzdqKuTCRsE= go.opentelemetry.io/collector/config/configopaque v0.89.0/go.mod h1:TPCHaU+QXiEV+JXbgyr6mSErTI9chwQyasDVMdJr3eY= go.opentelemetry.io/collector/config/configtelemetry v0.89.0 h1:NtRknYDfMgP1r8mnByo6qQQK8IBw/lF9Qke5f7VhGZ0=