From 3218d8a33d478551936eaff4259143f14fafd027 Mon Sep 17 00:00:00 2001 From: Tigran Najaryan <4194920+tigrannajaryan@users.noreply.github.com> Date: Tue, 3 Aug 2021 13:52:45 +0400 Subject: [PATCH] Change default OTLP/HTTP port number (#3743) This implements specification change https://github.com/open-telemetry/opentelemetry-specification/pull/1839 To make transition to new port numbers less painful OTLP receiver will also accept data on the legacy port numbers when it is configured to use the default endpoint. Users who use the default Collector config can continue sending data to the legacy ports and have a graceful period to update their senders to start sending to the new ports. --- .../docsgen/docsgen/testdata/otlp-receiver.json | 2 +- exporter/otlphttpexporter/README.md | 10 +++++----- receiver/otlpreceiver/README.md | 6 +++--- receiver/otlpreceiver/config.md | 2 +- receiver/otlpreceiver/config_test.go | 6 +++--- receiver/otlpreceiver/factory.go | 3 ++- receiver/otlpreceiver/otlp.go | 12 ++++++++++++ website_docs/configuration.md | 2 +- 8 files changed, 28 insertions(+), 15 deletions(-) diff --git a/cmd/configschema/docsgen/docsgen/testdata/otlp-receiver.json b/cmd/configschema/docsgen/docsgen/testdata/otlp-receiver.json index f49c095a7e9..42e67df1fb0 100644 --- a/cmd/configschema/docsgen/docsgen/testdata/otlp-receiver.json +++ b/cmd/configschema/docsgen/docsgen/testdata/otlp-receiver.json @@ -270,7 +270,7 @@ "Name": "endpoint", "Type": "", "Kind": "string", - "Default": "0.0.0.0:55681", + "Default": "0.0.0.0:4318", "Doc": "Endpoint configures the listening address for the server.\n", "Fields": null }, diff --git a/exporter/otlphttpexporter/README.md b/exporter/otlphttpexporter/README.md index cfd07400963..32d515a088a 100644 --- a/exporter/otlphttpexporter/README.md +++ b/exporter/otlphttpexporter/README.md @@ -9,18 +9,18 @@ incompatible way any time.* The following settings are required: -- `endpoint` (no default): The target base URL to send data to (e.g.: https://example.com:55681). +- `endpoint` (no default): The target base URL to send data to (e.g.: https://example.com:4318). To send each signal a corresponding path will be added to this base URL, i.e. for traces "/v1/traces" will appended, for metrics "/v1/metrics" will be appended, for logs "/v1/logs" will be appended. The following settings can be optionally configured: -- `traces_endpoint` (no default): The target URL to send trace data to (e.g.: https://example.com:55681/v1/traces). +- `traces_endpoint` (no default): The target URL to send trace data to (e.g.: https://example.com:4318/v1/traces). If this setting is present the `endpoint` setting is ignored for traces. -- `metrics_endpoint` (no default): The target URL to send metric data to (e.g.: https://example.com:55681/v1/metrics). +- `metrics_endpoint` (no default): The target URL to send metric data to (e.g.: https://example.com:4318/v1/metrics). If this setting is present the `endpoint` setting is ignored for metrics. -- `logs_endpoint` (no default): The target URL to send log data to (e.g.: https://example.com:55681/v1/logs). +- `logs_endpoint` (no default): The target URL to send log data to (e.g.: https://example.com:4318/v1/logs). If this setting is present the `endpoint` setting is ignored logs. - `insecure` (default = false): when set to true disables verifying the server's @@ -45,7 +45,7 @@ Example: ```yaml exporters: otlphttp: - endpoint: https://example.com:55681/v1/traces + endpoint: https://example.com:4318/v1/traces ``` The full list of settings exposed for this exporter are documented [here](./config.go) diff --git a/receiver/otlpreceiver/README.md b/receiver/otlpreceiver/README.md index 34f51c16bdf..2f75ea51de3 100644 --- a/receiver/otlpreceiver/README.md +++ b/receiver/otlpreceiver/README.md @@ -25,7 +25,7 @@ receivers: The following settings are configurable: -- `endpoint` (default = 0.0.0.0:4317 for grpc protocol, 0.0.0.0:55681 http protocol): +- `endpoint` (default = 0.0.0.0:4317 for grpc protocol, 0.0.0.0:4318 http protocol): host:port to which the receiver is going to receive data. The valid syntax is described at https://github.com/grpc/grpc/blob/master/doc/naming.md. @@ -46,7 +46,7 @@ serialization](https://developers.google.com/protocol-buffers/docs/proto3#json). To write traces with HTTP/JSON, `POST` to `[address]/v1/traces` for traces, to `[address]/v1/metrics` for metrics, to `[address]/v1/logs` for logs. The default -port is `55681`. +port is `4318`. The HTTP/JSON endpoint can also optionally configure [CORS](https://fetch.spec.whatwg.org/#cors-protocol), which is enabled by @@ -58,7 +58,7 @@ receivers: otlp: protocols: http: - endpoint: "localhost:55681" + endpoint: "localhost:4318" cors_allowed_origins: - http://test.com # Origins can have wildcards with *, use * by itself to match any origin. diff --git a/receiver/otlpreceiver/config.md b/receiver/otlpreceiver/config.md index c8d067f1084..0e30e5e2521 100644 --- a/receiver/otlpreceiver/config.md +++ b/receiver/otlpreceiver/config.md @@ -73,7 +73,7 @@ Config defines configuration for OTLP receiver. | Name | Type | Default | Docs | | ---- | ---- | ------- | ---- | -| endpoint |string| 0.0.0.0:55681 | Endpoint configures the listening address for the server. | +| endpoint |string| 0.0.0.0:4318 | Endpoint configures the listening address for the server. | | tls_settings |[configtls-TLSServerSetting](#configtls-TLSServerSetting)| | TLSSetting struct exposes TLS client configuration. | | cors_allowed_origins |[]string| | CorsOrigins are the allowed CORS origins for HTTP/JSON requests to grpc-gateway adapter for the OTLP receiver. See github.com/rs/cors An empty list means that CORS is not enabled at all. A wildcard (*) can be used to match any origin or one or more characters of an origin. | | cors_allowed_headers |[]string| | CorsHeaders are the allowed CORS headers for HTTP/JSON requests to grpc-gateway adapter for the OTLP receiver. See github.com/rs/cors CORS needs to be enabled first by providing a non-empty list in CorsOrigins A wildcard (*) can be used to match any header. | diff --git a/receiver/otlpreceiver/config_test.go b/receiver/otlpreceiver/config_test.go index 1e92b1c38ea..02f59e8c297 100644 --- a/receiver/otlpreceiver/config_test.go +++ b/receiver/otlpreceiver/config_test.go @@ -139,7 +139,7 @@ func TestLoadConfig(t *testing.T) { ReadBufferSize: 512 * 1024, }, HTTP: &confighttp.HTTPServerSettings{ - Endpoint: "0.0.0.0:55681", + Endpoint: "0.0.0.0:4318", TLSSetting: &configtls.TLSServerSetting{ TLSSetting: configtls.TLSSetting{ CertFile: "test.crt", @@ -155,7 +155,7 @@ func TestLoadConfig(t *testing.T) { ReceiverSettings: config.NewReceiverSettings(config.NewIDWithName(typeStr, "cors")), Protocols: Protocols{ HTTP: &confighttp.HTTPServerSettings{ - Endpoint: "0.0.0.0:55681", + Endpoint: "0.0.0.0:4318", CorsOrigins: []string{"https://*.test.com", "https://test.com"}, }, }, @@ -166,7 +166,7 @@ func TestLoadConfig(t *testing.T) { ReceiverSettings: config.NewReceiverSettings(config.NewIDWithName(typeStr, "corsheader")), Protocols: Protocols{ HTTP: &confighttp.HTTPServerSettings{ - Endpoint: "0.0.0.0:55681", + Endpoint: "0.0.0.0:4318", CorsOrigins: []string{"https://*.test.com", "https://test.com"}, CorsHeaders: []string{"ExampleHeader"}, }, diff --git a/receiver/otlpreceiver/factory.go b/receiver/otlpreceiver/factory.go index 24cb581e6e1..e2ee26c1e4e 100644 --- a/receiver/otlpreceiver/factory.go +++ b/receiver/otlpreceiver/factory.go @@ -31,8 +31,9 @@ const ( typeStr = "otlp" defaultGRPCEndpoint = "0.0.0.0:4317" - defaultHTTPEndpoint = "0.0.0.0:55681" + defaultHTTPEndpoint = "0.0.0.0:4318" legacyGRPCEndpoint = "0.0.0.0:55680" + legacyHTTPEndpoint = "0.0.0.0:55681" ) // NewFactory creates a new OTLP receiver factory. diff --git a/receiver/otlpreceiver/otlp.go b/receiver/otlpreceiver/otlp.go index f4646fc8027..a43f4381c00 100644 --- a/receiver/otlpreceiver/otlp.go +++ b/receiver/otlpreceiver/otlp.go @@ -155,6 +155,18 @@ func (r *otlpReceiver) startProtocolServers(host component.Host) error { if err != nil { return err } + if r.cfg.HTTP.Endpoint == defaultHTTPEndpoint { + r.logger.Info("Setting up a second HTTP listener on legacy endpoint " + legacyHTTPEndpoint) + + // Copy the config. + cfgLegacyHTTP := r.cfg.HTTP + // And use the legacy endpoint. + cfgLegacyHTTP.Endpoint = legacyHTTPEndpoint + err = r.startHTTPServer(cfgLegacyHTTP, host) + if err != nil { + return err + } + } } return err diff --git a/website_docs/configuration.md b/website_docs/configuration.md index 3067f3ed421..d2209bcf29c 100644 --- a/website_docs/configuration.md +++ b/website_docs/configuration.md @@ -330,7 +330,7 @@ exporters: # Data sources: traces, metrics otlphttp: - endpoint: https://example.com:55681/v1/traces + endpoint: https://example.com:4318/v1/traces # Data sources: metrics prometheus: