Skip to content

Commit 13ebcf5

Browse files
Change default OTLP/HTTP port number
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.
1 parent 5929f4f commit 13ebcf5

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

receiver/otlpreceiver/README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ receivers:
2525
2626
The following settings are configurable:
2727
28-
- `endpoint` (default = 0.0.0.0:4317 for grpc protocol, 0.0.0.0:55681 http protocol):
28+
- `endpoint` (default = 0.0.0.0:4317 for grpc protocol, 0.0.0.0:4318 http protocol):
2929
host:port to which the receiver is going to receive data. The valid syntax is
3030
described at https://github.com/grpc/grpc/blob/master/doc/naming.md.
3131

@@ -46,7 +46,7 @@ serialization](https://developers.google.com/protocol-buffers/docs/proto3#json).
4646

4747
To write traces with HTTP/JSON, `POST` to `[address]/v1/traces` for traces,
4848
to `[address]/v1/metrics` for metrics, to `[address]/v1/logs` for logs. The default
49-
port is `55681`.
49+
port is `4318`.
5050

5151
The HTTP/JSON endpoint can also optionally configure
5252
[CORS](https://fetch.spec.whatwg.org/#cors-protocol), which is enabled by
@@ -58,7 +58,7 @@ receivers:
5858
otlp:
5959
protocols:
6060
http:
61-
endpoint: "localhost:55681"
61+
endpoint: "localhost:4318"
6262
cors_allowed_origins:
6363
- http://test.com
6464
# Origins can have wildcards with *, use * by itself to match any origin.

receiver/otlpreceiver/config_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func TestLoadConfig(t *testing.T) {
139139
ReadBufferSize: 512 * 1024,
140140
},
141141
HTTP: &confighttp.HTTPServerSettings{
142-
Endpoint: "0.0.0.0:55681",
142+
Endpoint: "0.0.0.0:4318",
143143
TLSSetting: &configtls.TLSServerSetting{
144144
TLSSetting: configtls.TLSSetting{
145145
CertFile: "test.crt",
@@ -155,7 +155,7 @@ func TestLoadConfig(t *testing.T) {
155155
ReceiverSettings: config.NewReceiverSettings(config.NewIDWithName(typeStr, "cors")),
156156
Protocols: Protocols{
157157
HTTP: &confighttp.HTTPServerSettings{
158-
Endpoint: "0.0.0.0:55681",
158+
Endpoint: "0.0.0.0:4318",
159159
CorsOrigins: []string{"https://*.test.com", "https://test.com"},
160160
},
161161
},
@@ -166,7 +166,7 @@ func TestLoadConfig(t *testing.T) {
166166
ReceiverSettings: config.NewReceiverSettings(config.NewIDWithName(typeStr, "corsheader")),
167167
Protocols: Protocols{
168168
HTTP: &confighttp.HTTPServerSettings{
169-
Endpoint: "0.0.0.0:55681",
169+
Endpoint: "0.0.0.0:4318",
170170
CorsOrigins: []string{"https://*.test.com", "https://test.com"},
171171
CorsHeaders: []string{"ExampleHeader"},
172172
},

receiver/otlpreceiver/factory.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,9 @@ const (
3131
typeStr = "otlp"
3232

3333
defaultGRPCEndpoint = "0.0.0.0:4317"
34-
defaultHTTPEndpoint = "0.0.0.0:55681"
34+
defaultHTTPEndpoint = "0.0.0.0:4318"
3535
legacyGRPCEndpoint = "0.0.0.0:55680"
36+
legacyHTTPEndpoint = "0.0.0.0:55681"
3637
)
3738

3839
// NewFactory creates a new OTLP receiver factory.

receiver/otlpreceiver/otlp.go

+12
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,18 @@ func (r *otlpReceiver) startProtocolServers(host component.Host) error {
155155
if err != nil {
156156
return err
157157
}
158+
if r.cfg.HTTP.Endpoint == defaultHTTPEndpoint {
159+
r.logger.Info("Setting up a second HTTP listener on legacy endpoint " + legacyHTTPEndpoint)
160+
161+
// Copy the config.
162+
cfgLegacyHTTP := r.cfg.HTTP
163+
// And use the legacy endpoint.
164+
cfgLegacyHTTP.Endpoint = legacyHTTPEndpoint
165+
err = r.startHTTPServer(cfgLegacyHTTP, host)
166+
if err != nil {
167+
return err
168+
}
169+
}
158170
}
159171

160172
return err

0 commit comments

Comments
 (0)