Skip to content

Commit

Permalink
Change default OTLP/HTTP port number
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 Jul 30, 2021
1 parent 5929f4f commit 13ebcf5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
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
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

0 comments on commit 13ebcf5

Please sign in to comment.