diff --git a/receiver/rabbitmqreceiver/config.go b/receiver/rabbitmqreceiver/config.go index d81af2439331..bddc1c4dbc7a 100644 --- a/receiver/rabbitmqreceiver/config.go +++ b/receiver/rabbitmqreceiver/config.go @@ -11,7 +11,6 @@ import ( "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/config/configopaque" "go.opentelemetry.io/collector/receiver/scraperhelper" - "go.uber.org/multierr" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/rabbitmqreceiver/internal/metadata" ) @@ -37,20 +36,20 @@ type Config struct { // Validate validates the configuration by checking for missing or invalid fields func (cfg *Config) Validate() error { - var err error + var err []error if cfg.Username == "" { - err = multierr.Append(err, errMissingUsername) + err = append(err, errMissingUsername) } if cfg.Password == "" { - err = multierr.Append(err, errMissingPassword) + err = append(err, errMissingPassword) } _, parseErr := url.Parse(cfg.Endpoint) if parseErr != nil { wrappedErr := fmt.Errorf("%s: %w", errInvalidEndpoint.Error(), parseErr) - err = multierr.Append(err, wrappedErr) + err = append(err, wrappedErr) } - return err + return errors.Join(err...) } diff --git a/receiver/rabbitmqreceiver/config_test.go b/receiver/rabbitmqreceiver/config_test.go index c914ebc30973..c1e333cbfaf1 100644 --- a/receiver/rabbitmqreceiver/config_test.go +++ b/receiver/rabbitmqreceiver/config_test.go @@ -4,6 +4,7 @@ package rabbitmqreceiver // import "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/rabbitmqreceiver" import ( + "errors" "fmt" "path/filepath" "testing" @@ -13,7 +14,6 @@ import ( "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/config/confighttp" "go.opentelemetry.io/collector/confmap/confmaptest" - "go.uber.org/multierr" "github.com/open-telemetry/opentelemetry-collector-contrib/receiver/rabbitmqreceiver/internal/metadata" ) @@ -31,11 +31,10 @@ func TestValidate(t *testing.T) { Endpoint: "invalid://endpoint: 12efg", }, }, - expectedErr: multierr.Combine( + expectedErr: errors.Join( errMissingUsername, errMissingPassword, - fmt.Errorf("%w: %s", errInvalidEndpoint, `parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`), - ), + fmt.Errorf("%w: %s", errInvalidEndpoint, `parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`)), }, { desc: "missing password and invalid endpoint", @@ -45,7 +44,7 @@ func TestValidate(t *testing.T) { Endpoint: "invalid://endpoint: 12efg", }, }, - expectedErr: multierr.Combine( + expectedErr: errors.Join( errMissingPassword, fmt.Errorf("%w: %s", errInvalidEndpoint, `parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`), ), @@ -58,7 +57,7 @@ func TestValidate(t *testing.T) { Endpoint: "invalid://endpoint: 12efg", }, }, - expectedErr: multierr.Combine( + expectedErr: errors.Join( errMissingUsername, fmt.Errorf("%w: %s", errInvalidEndpoint, `parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`), ), @@ -72,7 +71,7 @@ func TestValidate(t *testing.T) { Endpoint: "invalid://endpoint: 12efg", }, }, - expectedErr: multierr.Combine( + expectedErr: errors.Join( fmt.Errorf("%w: %s", errInvalidEndpoint, `parse "invalid://endpoint: 12efg": invalid port ": 12efg" after host`), ), }, diff --git a/receiver/rabbitmqreceiver/go.mod b/receiver/rabbitmqreceiver/go.mod index a4f31f96aecf..392b4cac0353 100644 --- a/receiver/rabbitmqreceiver/go.mod +++ b/receiver/rabbitmqreceiver/go.mod @@ -18,7 +18,6 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 go.uber.org/goleak v1.3.0 - go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 ) @@ -65,6 +64,7 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.46.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.24.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.22.0 // indirect golang.org/x/sys v0.18.0 // indirect golang.org/x/text v0.14.0 // indirect