Skip to content

Commit 3686117

Browse files
atoulmemx-psi
andauthored
[receiver/sapm] sapmreceiver adopts component.UseLocalHostAsDefaultHost feature gate (#30926)
**Description:** sapmreceiver adopts `component.UseLocalHostAsDefaultHost` feature gate **Link to tracking Issue:** #30702 **Documentation:** Updated docs. --------- Co-authored-by: Pablo Baeyens <[email protected]>
1 parent b60fbd5 commit 3686117

File tree

5 files changed

+11
-8
lines changed

5 files changed

+11
-8
lines changed

.chloggen/mx-psi_internal-localhostgate.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ subtext: |
2727
- receiver/influxdb
2828
- receiver/zookeeper
2929
- receiver/signalfx
30+
- receiver/sapm
3031
- extension/jaegerremotesampling
3132
- receiver/jaeger
3233
- receiver/skywalking

receiver/sapmreceiver/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ The following settings are required:
2626

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

3031
The following setting are optional:
3132

receiver/sapmreceiver/config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func TestLoadConfig(t *testing.T) {
4444
id: component.NewIDWithName(metadata.Type, "tls"),
4545
expected: &Config{
4646
HTTPServerConfig: confighttp.HTTPServerConfig{
47-
Endpoint: ":7276",
47+
Endpoint: "0.0.0.0:7276",
4848
TLSSetting: &configtls.TLSServerSetting{
4949
TLSSetting: configtls.TLSSetting{
5050
CertFile: "/test.crt",
@@ -58,7 +58,7 @@ func TestLoadConfig(t *testing.T) {
5858
id: component.NewIDWithName(metadata.Type, "passthrough"),
5959
expected: &Config{
6060
HTTPServerConfig: confighttp.HTTPServerConfig{
61-
Endpoint: ":7276",
61+
Endpoint: "0.0.0.0:7276",
6262
},
6363
AccessTokenPassthroughConfig: splunk.AccessTokenPassthroughConfig{
6464
AccessTokenPassthrough: true,

receiver/sapmreceiver/factory.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,13 @@ import (
1616
"go.opentelemetry.io/collector/consumer"
1717
"go.opentelemetry.io/collector/receiver"
1818

19+
"github.com/open-telemetry/opentelemetry-collector-contrib/internal/common/localhostgate"
1920
"github.com/open-telemetry/opentelemetry-collector-contrib/receiver/sapmreceiver/internal/metadata"
2021
)
2122

2223
const (
23-
// Default endpoints to bind to.
24-
defaultEndpoint = ":7276"
24+
// Default port to bind to.
25+
defaultPort = 7276
2526
)
2627

2728
// NewFactory creates a factory for SAPM receiver.
@@ -35,7 +36,7 @@ func NewFactory() receiver.Factory {
3536
func createDefaultConfig() component.Config {
3637
return &Config{
3738
HTTPServerConfig: confighttp.HTTPServerConfig{
38-
Endpoint: defaultEndpoint,
39+
Endpoint: localhostgate.EndpointForPort(defaultPort),
3940
},
4041
}
4142
}

receiver/sapmreceiver/trace_receiver_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func TestReception(t *testing.T) {
279279
// 1. Create the SAPM receiver aka "server"
280280
config: &Config{
281281
HTTPServerConfig: confighttp.HTTPServerConfig{
282-
Endpoint: defaultEndpoint,
282+
Endpoint: "0.0.0.0:7226",
283283
},
284284
},
285285
sapm: &splunksapm.PostSpansRequest{Batches: []*model.Batch{grpcFixture(now)}},
@@ -293,7 +293,7 @@ func TestReception(t *testing.T) {
293293
args: args{
294294
config: &Config{
295295
HTTPServerConfig: confighttp.HTTPServerConfig{
296-
Endpoint: defaultEndpoint,
296+
Endpoint: "0.0.0.0:7226",
297297
},
298298
},
299299
sapm: &splunksapm.PostSpansRequest{Batches: []*model.Batch{grpcFixture(now)}},
@@ -382,7 +382,7 @@ func TestAccessTokenPassthrough(t *testing.T) {
382382
t.Run(tt.name, func(t *testing.T) {
383383
config := &Config{
384384
HTTPServerConfig: confighttp.HTTPServerConfig{
385-
Endpoint: defaultEndpoint,
385+
Endpoint: "0.0.0.0:7226",
386386
},
387387
AccessTokenPassthroughConfig: splunk.AccessTokenPassthroughConfig{
388388
AccessTokenPassthrough: tt.accessTokenPassthrough,

0 commit comments

Comments
 (0)