Skip to content

Commit

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

Fixes open-telemetry#30867
  • Loading branch information
mx-psi committed Jan 30, 2024
1 parent c302fba commit b96f7cd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 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 @@ -20,6 +20,7 @@ subtext: |
- receiver/loki
- receiver/opencensus
- receiver/zipkin
- 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 @@ -14,9 +14,11 @@ import (
"go.opentelemetry.io/collector/receiver/scraperhelper"

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

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

0 comments on commit b96f7cd

Please sign in to comment.