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/zookeeper] Use component.UseLocalHostAsDefaultHost feature gate #30868

Merged
merged 6 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
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
Loading