Skip to content

Commit 2c254ea

Browse files
mx-psicparkins
authored andcommitted
[receiver/zookeeper] Use component.UseLocalHostAsDefaultHost feature gate (open-telemetry#30868)
**Description:** Fixes open-telemetry#30867
1 parent 71a3d76 commit 2c254ea

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

.chloggen/mx-psi_internal-localhostgate.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ subtext: |
2525
- receiver/splunk_hec
2626
- receiver/awsxray
2727
- receiver/influxdb
28+
- receiver/zookeeper
2829
2930
# If your change doesn't affect end users or the exported elements of any package,
3031
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.

receiver/zookeeperreceiver/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ to be enabled for the receiver to be able to collect metrics.
1919

2020
## Configuration
2121

22-
- `endpoint`: (default = `:2181`) Endpoint to connect to collect metrics. Takes the form `host:port`.
22+
- `endpoint`: (default = `0.0.0.0:2181`) Endpoint to connect to collect metrics. Takes the form `host:port`. The `component.UseLocalHostAsDefaultHost` feature gate changes this to localhost:2181. This will become the default in a future release.
2323
- `timeout`: (default = `10s`) Timeout within which requests should be completed.
2424
- `initial_delay` (default = `1s`): defines how long this receiver waits before starting.
2525

receiver/zookeeperreceiver/factory.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ import (
1313
"go.opentelemetry.io/collector/receiver"
1414
"go.opentelemetry.io/collector/receiver/scraperhelper"
1515

16+
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate"
1617
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zookeeperreceiver/internal/metadata"
1718
)
1819

1920
const (
21+
defaultPort = 2181
2022
defaultCollectionInterval = 10 * time.Second
2123
defaultTimeout = 10 * time.Second
2224
)
@@ -37,7 +39,7 @@ func createDefaultConfig() component.Config {
3739
return &Config{
3840
ScraperControllerSettings: cfg,
3941
TCPAddr: confignet.TCPAddr{
40-
Endpoint: ":2181",
42+
Endpoint: localhostgate.EndpointForPort(defaultPort),
4143
},
4244
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
4345
}

receiver/zookeeperreceiver/factory_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestFactory(t *testing.T) {
2626
// Assert defaults.
2727
assert.Equal(t, 10*time.Second, rCfg.CollectionInterval)
2828
assert.Equal(t, 10*time.Second, rCfg.Timeout)
29-
assert.Equal(t, ":2181", rCfg.Endpoint)
29+
assert.Equal(t, "0.0.0.0:2181", rCfg.Endpoint)
3030

3131
tests := []struct {
3232
name string

0 commit comments

Comments
 (0)