Skip to content

Commit

Permalink
Change default OTLP/HTTP port number (#3743)
Browse files Browse the repository at this point in the history
This implements specification change open-telemetry/opentelemetry-specification#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.
  • Loading branch information
tigrannajaryan committed Aug 3, 2021
1 parent 9fd1f5f commit 3218d8a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
},
Expand Down
10 changes: 5 additions & 5 deletions exporter/otlphttpexporter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions receiver/otlpreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand All @@ -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
Expand All @@ -58,7 +58,7 @@ receivers:
otlp:
protocols:
http:
endpoint: "localhost:55681"
endpoint: "localhost:4318"
cors_allowed_origins:
- http:https://test.com
# Origins can have wildcards with *, use * by itself to match any origin.
Expand Down
2 changes: 1 addition & 1 deletion receiver/otlpreceiver/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)| <no value> | TLSSetting struct exposes TLS client configuration. |
| cors_allowed_origins |[]string| <no value> | 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| <no value> | 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. |
Expand Down
6 changes: 3 additions & 3 deletions receiver/otlpreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"},
},
},
Expand All @@ -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"},
},
Expand Down
3 changes: 2 additions & 1 deletion receiver/otlpreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions receiver/otlpreceiver/otlp.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion website_docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 3218d8a

Please sign in to comment.