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

[chore] [receiver/apachespark] Use NewDefaultClientConfig instead of manually creating struct #35578

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions receiver/apachesparkreceiver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ const (
)

func TestNewApacheSparkClient(t *testing.T) {
clientConfig := confighttp.NewDefaultClientConfig()
clientConfig.Endpoint = defaultEndpoint
testCases := []struct {
desc string
cfg *Config
Expand All @@ -39,9 +41,7 @@ func TestNewApacheSparkClient(t *testing.T) {
{
desc: "Valid Configuration",
cfg: &Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: defaultEndpoint,
},
ClientConfig: clientConfig,
},
host: componenttest.NewNopHost(),
settings: componenttest.NewNopTelemetrySettings(),
Expand Down
6 changes: 3 additions & 3 deletions receiver/apachesparkreceiver/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
)

func TestValidate(t *testing.T) {
clientConfig := confighttp.NewDefaultClientConfig()
clientConfig.Endpoint = "invalid://endpoint 12efg"
testCases := []struct {
desc string
cfg *Config
Expand All @@ -27,9 +29,7 @@ func TestValidate(t *testing.T) {
{
desc: "invalid endpoint",
cfg: &Config{
ClientConfig: confighttp.ClientConfig{
Endpoint: "invalid://endpoint 12efg",
},
ClientConfig: clientConfig,
ControllerConfig: scraperhelper.NewDefaultControllerConfig(),
},
expectedErr: errInvalidEndpoint,
Expand Down
9 changes: 4 additions & 5 deletions receiver/apachesparkreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ func NewFactory() receiver.Factory {
func createDefaultConfig() component.Config {
cfg := scraperhelper.NewDefaultControllerConfig()
cfg.CollectionInterval = defaultCollectionInterval

clientConfig := confighttp.NewDefaultClientConfig()
clientConfig.Endpoint = defaultEndpoint
return &Config{
ControllerConfig: cfg,
ClientConfig: confighttp.ClientConfig{
Endpoint: defaultEndpoint,
},
ControllerConfig: cfg,
ClientConfig: clientConfig,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}
}
Expand Down
7 changes: 4 additions & 3 deletions receiver/apachesparkreceiver/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ import (
)

func TestNewFactory(t *testing.T) {
clientConfig := confighttp.NewDefaultClientConfig()
clientConfig.Endpoint = defaultEndpoint

testCases := []struct {
desc string
testFunc func(*testing.T)
Expand All @@ -40,9 +43,7 @@ func TestNewFactory(t *testing.T) {
CollectionInterval: defaultCollectionInterval,
InitialDelay: time.Second,
},
ClientConfig: confighttp.ClientConfig{
Endpoint: defaultEndpoint,
},
ClientConfig: clientConfig,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
}

Expand Down
2 changes: 1 addition & 1 deletion receiver/apachesparkreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ require (
github.com/testcontainers/testcontainers-go v0.31.0
go.opentelemetry.io/collector/component v0.110.0
go.opentelemetry.io/collector/config/confighttp v0.110.0
go.opentelemetry.io/collector/config/configopaque v1.16.0
go.opentelemetry.io/collector/confmap v1.16.0
go.opentelemetry.io/collector/consumer v0.110.0
go.opentelemetry.io/collector/consumer/consumertest v0.110.0
Expand Down Expand Up @@ -80,7 +81,6 @@ require (
go.opentelemetry.io/collector/component/componentprofiles v0.110.0 // indirect
go.opentelemetry.io/collector/config/configauth v0.110.0 // indirect
go.opentelemetry.io/collector/config/configcompression v1.16.0 // indirect
go.opentelemetry.io/collector/config/configopaque v1.16.0 // indirect
go.opentelemetry.io/collector/config/configtelemetry v0.110.0 // indirect
go.opentelemetry.io/collector/config/configtls v1.16.0 // indirect
go.opentelemetry.io/collector/config/internal v0.110.0 // indirect
Expand Down
14 changes: 6 additions & 8 deletions receiver/apachesparkreceiver/scraper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const (
)

func TestScraper(t *testing.T) {
clientConfig := confighttp.NewDefaultClientConfig()
clientConfig.Endpoint = defaultEndpoint
testcases := []struct {
desc string
setupMockClient func(t *testing.T) client
Expand Down Expand Up @@ -68,10 +70,8 @@ func TestScraper(t *testing.T) {
config: &Config{ControllerConfig: scraperhelper.ControllerConfig{
CollectionInterval: defaultCollectionInterval,
},
ApplicationNames: []string{"local-123", "local-987"},
ClientConfig: confighttp.ClientConfig{
Endpoint: defaultEndpoint,
},
ApplicationNames: []string{"local-123", "local-987"},
ClientConfig: clientConfig,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
},
expectedErr: errNoMatchingAllowedApps,
Expand Down Expand Up @@ -215,10 +215,8 @@ func TestScraper(t *testing.T) {
config: &Config{ControllerConfig: scraperhelper.ControllerConfig{
CollectionInterval: defaultCollectionInterval,
},
ApplicationNames: []string{"streaming-example"},
ClientConfig: confighttp.ClientConfig{
Endpoint: defaultEndpoint,
},
ApplicationNames: []string{"streaming-example"},
ClientConfig: clientConfig,
MetricsBuilderConfig: metadata.DefaultMetricsBuilderConfig(),
},
expectedErr: nil,
Expand Down