Skip to content

Commit 80bbf5e

Browse files
authored
[chore] Sync internal/common/localhostgate (open-telemetry#31965)
**Description:** Syncs localhostgate with core after changes in open-telemetry/opentelemetry-collector/pull/9852
1 parent 101b8b1 commit 80bbf5e

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

internal/common/localhostgate/featuregate.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@ import (
1818

1919
const UseLocalHostAsDefaultHostID = "component.UseLocalHostAsDefaultHost"
2020

21-
// useLocalHostAsDefaultHostfeatureGate is the feature gate that controls whether
21+
// UseLocalHostAsDefaultHostfeatureGate is the feature gate that controls whether
2222
// server-like receivers and extensions such as the OTLP receiver use localhost as the default host for their endpoints.
23-
var useLocalHostAsDefaultHostfeatureGate = mustRegisterOrLoad(
23+
var UseLocalHostAsDefaultHostfeatureGate = mustRegisterOrLoad(
2424
featuregate.GlobalRegistry(),
2525
UseLocalHostAsDefaultHostID,
2626
featuregate.StageAlpha,
@@ -51,15 +51,15 @@ func mustRegisterOrLoad(reg *featuregate.Registry, id string, stage featuregate.
5151
// EndpointForPort gets the endpoint for a given port using localhost or 0.0.0.0 depending on the feature gate.
5252
func EndpointForPort(port int) string {
5353
host := "localhost"
54-
if !useLocalHostAsDefaultHostfeatureGate.IsEnabled() {
54+
if !UseLocalHostAsDefaultHostfeatureGate.IsEnabled() {
5555
host = "0.0.0.0"
5656
}
5757
return fmt.Sprintf("%s:%d", host, port)
5858
}
5959

6060
// LogAboutUseLocalHostAsDefault logs about the upcoming change from 0.0.0.0 to localhost on server-like components.
6161
func LogAboutUseLocalHostAsDefault(logger *zap.Logger) {
62-
if !useLocalHostAsDefaultHostfeatureGate.IsEnabled() {
62+
if !UseLocalHostAsDefaultHostfeatureGate.IsEnabled() {
6363
logger.Warn(
6464
"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.",
6565
zap.String("feature gate ID", UseLocalHostAsDefaultHostID),

internal/common/localhostgate/featuregate_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestEndpointForPort(t *testing.T) {
4949

5050
for _, tt := range tests {
5151
t.Run(tt.endpoint, func(t *testing.T) {
52-
defer setFeatureGateForTest(t, useLocalHostAsDefaultHostfeatureGate, tt.enabled)()
52+
defer setFeatureGateForTest(t, UseLocalHostAsDefaultHostfeatureGate, tt.enabled)()
5353
assert.Equal(t, EndpointForPort(tt.port), tt.endpoint)
5454
})
5555
}

0 commit comments

Comments
 (0)