Skip to content

Commit

Permalink
[receiver/skywalking] adopt the component.UseLocalHostAsDefaultHost
Browse files Browse the repository at this point in the history
… feature gate (#30978)

Description:
skywalkingreceiver adopts component.UseLocalHostAsDefaultHost feature
gate

Link to tracking Issue:

#30702

Fixes #30977 

Documentation:
Updated docs.
  • Loading branch information
atoulme committed Feb 1, 2024
1 parent 7a5874d commit 759847a
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 11 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 @@ -27,6 +27,7 @@ subtext: |
- receiver/influxdb
- receiver/zookeeper
- receiver/signalfx
- receiver/skywalking
# 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
4 changes: 4 additions & 0 deletions receiver/skywalkingreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ object configuration parameter.
- `grpc` (default `endpoint` = 0.0.0.0:11800)
- `http` (default `endpoint` = 0.0.0.0:12800)

The `component.UseLocalHostAsDefaultHost` feature gate changes endpoints to localhost:11800 and localhost:12800 respectively.
This will become the default in a future release.


Examples:

```yaml
Expand Down
2 changes: 1 addition & 1 deletion receiver/skywalkingreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func TestLoadConfig(t *testing.T) {
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: "0.0.0.0:11800",
Transport: "tcp",
},
},
Expand Down
11 changes: 6 additions & 5 deletions receiver/skywalkingreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import (
"go.opentelemetry.io/collector/consumer"
"go.opentelemetry.io/collector/receiver"

"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate"
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent"
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/skywalkingreceiver/internal/metadata"
)
Expand All @@ -27,9 +28,9 @@ const (
protoGRPC = "grpc"
protoHTTP = "http"

// Default endpoints to bind to.
defaultGRPCBindEndpoint = "0.0.0.0:11800"
defaultHTTPBindEndpoint = "0.0.0.0:12800"
// Default ports to bind to.
defaultGRPCPort = 11800
defaultHTTPPort = 12800
)

// NewFactory creates a new Skywalking receiver factory.
Expand All @@ -47,12 +48,12 @@ func createDefaultConfig() component.Config {
Protocols: Protocols{
GRPC: &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: localhostgate.EndpointForPort(defaultGRPCPort),
Transport: "tcp",
},
},
HTTP: &confighttp.HTTPServerConfig{
Endpoint: defaultHTTPBindEndpoint,
Endpoint: localhostgate.EndpointForPort(defaultHTTPPort),
},
},
}
Expand Down
10 changes: 5 additions & 5 deletions receiver/skywalkingreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestCreateReceiver(t *testing.T) {
// have to enable at least one protocol for the skywalking receiver to be created
cfg.(*Config).Protocols.GRPC = &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: "0.0.0.0:11800",
Transport: "tcp",
},
}
Expand Down Expand Up @@ -88,7 +88,7 @@ func TestCreateDefaultGRPCEndpoint(t *testing.T) {

cfg.(*Config).Protocols.GRPC = &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: "0.0.0.0:11800",
Transport: "tcp",
},
}
Expand All @@ -106,7 +106,7 @@ func TestCreateTLSGPRCEndpoint(t *testing.T) {

cfg.(*Config).Protocols.GRPC = &configgrpc.GRPCServerSettings{
NetAddr: confignet.NetAddr{
Endpoint: defaultGRPCBindEndpoint,
Endpoint: "0.0.0.0:11800",
Transport: "tcp",
},
TLSSetting: &configtls.TLSServerSetting{
Expand All @@ -127,7 +127,7 @@ func TestCreateTLSHTTPEndpoint(t *testing.T) {
cfg := factory.CreateDefaultConfig()

cfg.(*Config).Protocols.HTTP = &confighttp.HTTPServerConfig{
Endpoint: defaultHTTPBindEndpoint,
Endpoint: "0.0.0.0:12800",
TLSSetting: &configtls.TLSServerSetting{
TLSSetting: configtls.TLSSetting{
CertFile: "./testdata/server.crt",
Expand All @@ -147,7 +147,7 @@ func TestCreateInvalidHTTPEndpoint(t *testing.T) {
cfg := factory.CreateDefaultConfig()

cfg.(*Config).Protocols.HTTP = &confighttp.HTTPServerConfig{
Endpoint: defaultHTTPBindEndpoint,
Endpoint: "0.0.0.0:12800",
}
set := receivertest.NewNopCreateSettings()
traceSink := new(consumertest.TracesSink)
Expand Down
3 changes: 3 additions & 0 deletions receiver/skywalkingreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.20

require (
github.com/gorilla/mux v1.8.1
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common v0.93.0
github.com/open-telemetry/opentelemetry-collector-contrib/internal/sharedcomponent v0.93.0
github.com/open-telemetry/opentelemetry-collector-contrib/pkg/translator/skywalking v0.93.0
github.com/stretchr/testify v1.8.4
Expand Down Expand Up @@ -89,3 +90,5 @@ retract (
v0.76.1
v0.65.0
)

replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common

0 comments on commit 759847a

Please sign in to comment.