Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[receiver/otlp] Promote component.UseLocalHostAsDefaultHost to beta #10352

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
TylerHelmuth marked this conversation as resolved.
Show resolved Hide resolved

# 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/otel/exporters/prometheus v0.49.0 // indirect
go.opentelemetry.io/otel/metric v1.27.0 // indirect
go.opentelemetry.io/otel/sdk 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 @@ -514,6 +516,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 @@
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 @@
// 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.",

Check warning on line 64 in internal/localhostgate/featuregate.go

View check run for this annotation

Codecov / codecov/patch

internal/localhostgate/featuregate.go#L63-L64

Added lines #L63 - L64 were not covered by tests
zap.String("feature gate ID", UseLocalHostAsDefaultHostID),
)
}
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
Loading