Skip to content

Commit

Permalink
[receiver/sapm] sapmreceiver adopts `component.UseLocalHostAsDefaultH…
Browse files Browse the repository at this point in the history
…ost` feature gate (open-telemetry#30926)

**Description:**
sapmreceiver adopts `component.UseLocalHostAsDefaultHost` feature gate

**Link to tracking Issue:**
open-telemetry#30702 

**Documentation:**
Updated docs.

---------

Co-authored-by: Pablo Baeyens <pbaeyens31+github@gmail.com>
  • Loading branch information
2 people authored and cparkins committed Feb 1, 2024
1 parent 05c76dc commit 93c9722
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 8 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/sapm
- extension/jaegerremotesampling
- receiver/jaeger
- receiver/skywalking
Expand Down
1 change: 1 addition & 0 deletions receiver/sapmreceiver/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ The following settings are required:

- `endpoint` (default = `0.0.0.0:7276`): Address and port that the SAPM
receiver should bind to.
The `component.UseLocalHostAsDefaultHost` feature gate changes this to localhost:7276. This will become the default in a future release.

The following setting are optional:

Expand Down
4 changes: 2 additions & 2 deletions receiver/sapmreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func TestLoadConfig(t *testing.T) {
id: component.NewIDWithName(metadata.Type, "tls"),
expected: &Config{
HTTPServerConfig: confighttp.HTTPServerConfig{
Endpoint: ":7276",
Endpoint: "0.0.0.0:7276",
TLSSetting: &configtls.TLSServerSetting{
TLSSetting: configtls.TLSSetting{
CertFile: "/test.crt",
Expand All @@ -58,7 +58,7 @@ func TestLoadConfig(t *testing.T) {
id: component.NewIDWithName(metadata.Type, "passthrough"),
expected: &Config{
HTTPServerConfig: confighttp.HTTPServerConfig{
Endpoint: ":7276",
Endpoint: "0.0.0.0:7276",
},
AccessTokenPassthroughConfig: splunk.AccessTokenPassthroughConfig{
AccessTokenPassthrough: true,
Expand Down
7 changes: 4 additions & 3 deletions receiver/sapmreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ 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/receiver/sapmreceiver/internal/metadata"
)

const (
// Default endpoints to bind to.
defaultEndpoint = ":7276"
// Default port to bind to.
defaultPort = 7276
)

// NewFactory creates a factory for SAPM receiver.
Expand All @@ -35,7 +36,7 @@ func NewFactory() receiver.Factory {
func createDefaultConfig() component.Config {
return &Config{
HTTPServerConfig: confighttp.HTTPServerConfig{
Endpoint: defaultEndpoint,
Endpoint: localhostgate.EndpointForPort(defaultPort),
},
}
}
Expand Down
6 changes: 3 additions & 3 deletions receiver/sapmreceiver/trace_receiver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func TestReception(t *testing.T) {
// 1. Create the SAPM receiver aka "server"
config: &Config{
HTTPServerConfig: confighttp.HTTPServerConfig{
Endpoint: defaultEndpoint,
Endpoint: "0.0.0.0:7226",
},
},
sapm: &splunksapm.PostSpansRequest{Batches: []*model.Batch{grpcFixture(now)}},
Expand All @@ -293,7 +293,7 @@ func TestReception(t *testing.T) {
args: args{
config: &Config{
HTTPServerConfig: confighttp.HTTPServerConfig{
Endpoint: defaultEndpoint,
Endpoint: "0.0.0.0:7226",
},
},
sapm: &splunksapm.PostSpansRequest{Batches: []*model.Batch{grpcFixture(now)}},
Expand Down Expand Up @@ -382,7 +382,7 @@ func TestAccessTokenPassthrough(t *testing.T) {
t.Run(tt.name, func(t *testing.T) {
config := &Config{
HTTPServerConfig: confighttp.HTTPServerConfig{
Endpoint: defaultEndpoint,
Endpoint: "0.0.0.0:7226",
},
AccessTokenPassthroughConfig: splunk.AccessTokenPassthroughConfig{
AccessTokenPassthrough: tt.accessTokenPassthrough,
Expand Down

0 comments on commit 93c9722

Please sign in to comment.