Skip to content

Commit

Permalink
[receiver/zookeeper] Use component.UseLocalHostAsDefaultHost feature …
Browse files Browse the repository at this point in the history
…gate (#30868)

**Description:** Fixes #30867
  • Loading branch information
mx-psi committed Jan 31, 2024
1 parent 8b8f610 commit cc2213d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions .chloggen/mx-psi_internal-localhostgate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ subtext: |
- receiver/splunk_hec
- receiver/awsxray
- receiver/influxdb
- receiver/zookeeper
# If your change doesn't affect end users or the exported elements of any package,
# you should instead start your pull request title with [chore] or use the "Skip Changelog" label.
Expand Down
2 changes: 1 addition & 1 deletion receiver/zookeeperreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ to be enabled for the receiver to be able to collect metrics.

## Configuration

- `endpoint`: (default = `:2181`) Endpoint to connect to collect metrics. Takes the form `host:port`.
- `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.
- `timeout`: (default = `10s`) Timeout within which requests should be completed.
- `initial_delay` (default = `1s`): defines how long this receiver waits before starting.

Expand Down
4 changes: 3 additions & 1 deletion receiver/zookeeperreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
"go.opentelemetry.io/collector/receiver"
"go.opentelemetry.io/collector/receiver/scraperhelper"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/zookeeperreceiver/internal/metadata"
)

const (
defaultPort = 2181
defaultCollectionInterval = 10 * time.Second
defaultTimeout = 10 * time.Second
)
Expand All @@ -37,7 +39,7 @@ func createDefaultConfig() component.Config {
return &Config{
ScraperControllerSettings: cfg,
TCPAddr: confignet.TCPAddr{
Endpoint: ":2181",
Endpoint: localhostgate.EndpointForPort(defaultPort),
},
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/zookeeperreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func TestFactory(t *testing.T) {
// Assert defaults.
assert.Equal(t, 10*time.Second, rCfg.CollectionInterval)
assert.Equal(t, 10*time.Second, rCfg.Timeout)
assert.Equal(t, ":2181", rCfg.Endpoint)
assert.Equal(t, "0.0.0.0:2181", rCfg.Endpoint)

tests := []struct {
name string
Expand Down

0 comments on commit cc2213d

Please sign in to comment.