Skip to content

Commit

Permalink
[receiver/otlp] Promote component.UseLocalHostAsDefaultHost to beta (
Browse files Browse the repository at this point in the history
…#10352)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

<!-- Issue number if applicable -->

Promotes `component.UseLocalHostAsDefaultHost` feature gate to beta.

#### Link to tracking issue

Updates #8510
  • Loading branch information
mx-psi committed Jun 27, 2024
1 parent f47b9f2 commit fead8fc
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 8 deletions.
26 changes: 26 additions & 0 deletions .chloggen/mx-psi_enable-component-localhost-fgh.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Use this changelog template to create an entry for release notes.

# One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix'
change_type: breaking

# The name of the component, or a single word describing the area of concern, (e.g. otlpreceiver)
component: otlpreceiver

# A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`).
note: Switch to `localhost` as the default for all endpoints.

# One or more tracking issues or pull requests related to the change
issues: [8510]

# (Optional) One or more lines of additional information to render under the primary note.
# These lines will be padded with 2 spaces and then inserted directly into the document.
# Use pipe (|) for multiline entries.
subtext: |
Disable the `component.UseLocalHostAsDefaultHost` feature gate to temporarily get the previous default.
# Optional: The change log or logs in which this entry should be included.
# e.g. '[user]' or '[user, api]'
# Include 'user' if the change is relevant to end users.
# Include 'api' if there is a change to a library API.
# Default: '[user]'
change_logs: []
9 changes: 9 additions & 0 deletions config/configgrpc/configgrpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ import (
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/extension/auth"
"go.opentelemetry.io/collector/extension/auth/authtest"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/internal/localhostgate"
"go.opentelemetry.io/collector/pdata/ptrace/ptraceotlp"
)

Expand Down Expand Up @@ -437,6 +439,13 @@ func TestUseSecure(t *testing.T) {
}

func TestGRPCServerWarning(t *testing.T) {
prev := localhostgate.UseLocalHostAsDefaultHostfeatureGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(localhostgate.UseLocalHostAsDefaultHostID, false))
defer func() {
// Restore previous value.
require.NoError(t, featuregate.GlobalRegistry().Set(localhostgate.UseLocalHostAsDefaultHostID, prev))
}()

tests := []struct {
name string
settings ServerConfig
Expand Down
2 changes: 1 addition & 1 deletion config/configgrpc/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ require (
go.opentelemetry.io/collector/config/configtls v0.103.0
go.opentelemetry.io/collector/config/internal v0.103.0
go.opentelemetry.io/collector/extension/auth v0.103.0
go.opentelemetry.io/collector/featuregate v1.10.0
go.opentelemetry.io/collector/pdata v1.10.0
go.opentelemetry.io/collector/pdata/testdata v0.103.0
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.52.0
Expand Down Expand Up @@ -51,7 +52,6 @@ require (
github.com/prometheus/procfs v0.15.0 // indirect
go.opentelemetry.io/collector/confmap v0.103.0 // indirect
go.opentelemetry.io/collector/extension v0.103.0 // indirect
go.opentelemetry.io/collector/featuregate v1.10.0 // indirect
go.opentelemetry.io/collector/pdata/pprofile v0.103.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.49.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
Expand Down
9 changes: 9 additions & 0 deletions config/confighttp/confighttp_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ import (
"go.opentelemetry.io/collector/config/configtls"
"go.opentelemetry.io/collector/extension/auth"
"go.opentelemetry.io/collector/extension/auth/authtest"
"go.opentelemetry.io/collector/featuregate"
"go.opentelemetry.io/collector/internal/localhostgate"
)

type customRoundTripper struct {
Expand Down Expand Up @@ -515,6 +517,13 @@ func TestHTTPServerSettingsError(t *testing.T) {
}

func TestHTTPServerWarning(t *testing.T) {
prev := localhostgate.UseLocalHostAsDefaultHostfeatureGate.IsEnabled()
require.NoError(t, featuregate.GlobalRegistry().Set(localhostgate.UseLocalHostAsDefaultHostID, false))
defer func() {
// Restore previous value.
require.NoError(t, featuregate.GlobalRegistry().Set(localhostgate.UseLocalHostAsDefaultHostID, prev))
}()

tests := []struct {
name string
settings ServerConfig
Expand Down
2 changes: 1 addition & 1 deletion config/confighttp/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ require (
go.opentelemetry.io/collector/config/configtls v0.103.0
go.opentelemetry.io/collector/config/internal v0.103.0
go.opentelemetry.io/collector/extension/auth v0.103.0
go.opentelemetry.io/collector/featuregate v1.10.0
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.52.0
go.opentelemetry.io/otel v1.27.0
go.uber.org/goleak v1.3.0
Expand Down Expand Up @@ -46,7 +47,6 @@ require (
github.com/prometheus/procfs v0.15.0 // indirect
go.opentelemetry.io/collector/confmap v0.103.0 // indirect
go.opentelemetry.io/collector/extension v0.103.0 // indirect
go.opentelemetry.io/collector/featuregate v1.10.0 // indirect
go.opentelemetry.io/collector/pdata v1.10.0 // indirect
go.opentelemetry.io/otel/exporters/prometheus v0.49.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
Expand Down
6 changes: 3 additions & 3 deletions internal/localhostgate/featuregate.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const UseLocalHostAsDefaultHostID = "component.UseLocalHostAsDefaultHost"
var UseLocalHostAsDefaultHostfeatureGate = mustRegisterOrLoad(
featuregate.GlobalRegistry(),
UseLocalHostAsDefaultHostID,
featuregate.StageAlpha,
featuregate.StageBeta,
featuregate.WithRegisterDescription("controls whether server-like receivers and extensions such as the OTLP receiver use localhost as the default host for their endpoints"),
)

Expand Down Expand Up @@ -60,8 +60,8 @@ func EndpointForPort(port int) string {
// LogAboutUseLocalHostAsDefault logs about the upcoming change from 0.0.0.0 to localhost on server-like components.
func LogAboutUseLocalHostAsDefault(logger *zap.Logger) {
if !UseLocalHostAsDefaultHostfeatureGate.IsEnabled() {
logger.Warn(
"The default endpoints for all servers in components will change to use localhost instead of 0.0.0.0 in a future version. Use the feature gate to preview the new default.",
logger.Info(
"The default endpoints for all servers in components have changed to use localhost instead of 0.0.0.0. Use the feature gate to temporarily revert to the previous default.",
zap.String("feature gate ID", UseLocalHostAsDefaultHostID),
)
}
Expand Down
2 changes: 1 addition & 1 deletion otelcol/testdata/otel-log-to-file.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exporters:
service:
telemetry:
logs:
level: warn
level: info
output_paths:
# The folder need to be created prior to starting the collector
- ${ProgramData}\OpenTelemetry\Collector\Logs\otelcol.log
Expand Down
4 changes: 2 additions & 2 deletions receiver/otlpreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func TestUnmarshalConfig(t *testing.T) {
Protocols: Protocols{
GRPC: &configgrpc.ServerConfig{
NetAddr: confignet.AddrConfig{
Endpoint: "0.0.0.0:4317",
Endpoint: "localhost:4317",
Transport: confignet.TransportTypeTCP,
},
TLSSetting: &configtls.ServerConfig{
Expand Down Expand Up @@ -117,7 +117,7 @@ func TestUnmarshalConfig(t *testing.T) {
},
HTTP: &HTTPConfig{
ServerConfig: &confighttp.ServerConfig{
Endpoint: "0.0.0.0:4318",
Endpoint: "localhost:4318",
TLSSetting: &configtls.ServerConfig{
Config: configtls.Config{
CertFile: "test.crt",
Expand Down

0 comments on commit fead8fc

Please sign in to comment.