From 9fac02fbe8a417fb94ebb6e8972a294b8cd9f442 Mon Sep 17 00:00:00 2001 From: Roger Coll Date: Tue, 14 May 2024 18:54:18 +0200 Subject: [PATCH] remove multierr from elasticsearch receiver --- receiver/elasticsearchreceiver/config.go | 13 +++++-------- receiver/elasticsearchreceiver/go.mod | 2 +- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/receiver/elasticsearchreceiver/config.go b/receiver/elasticsearchreceiver/config.go index 06c71ea112cf..7c81fc75350f 100644 --- a/receiver/elasticsearchreceiver/config.go +++ b/receiver/elasticsearchreceiver/config.go @@ -11,14 +11,11 @@ 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/elasticsearchreceiver/internal/metadata" ) -var ( - defaultEndpoint = "http://localhost:9200" -) +var defaultEndpoint = "http://localhost:9200" var ( errEndpointBadScheme = errors.New("endpoint scheme must be http or https") @@ -54,16 +51,16 @@ type Config struct { func (cfg *Config) Validate() error { var combinedErr error if err := invalidCredentials(cfg.Username, string(cfg.Password)); err != nil { - combinedErr = multierr.Append(combinedErr, err) + combinedErr = err } if cfg.Endpoint == "" { - return multierr.Append(combinedErr, errEmptyEndpoint) + return errors.Join(combinedErr, errEmptyEndpoint) } u, err := url.Parse(cfg.Endpoint) if err != nil { - return multierr.Append( + return errors.Join( combinedErr, fmt.Errorf("invalid endpoint '%s': %w", cfg.Endpoint, err), ) @@ -72,7 +69,7 @@ func (cfg *Config) Validate() error { switch u.Scheme { case "http", "https": // ok default: - return multierr.Append(combinedErr, errEndpointBadScheme) + return errors.Join(combinedErr, errEndpointBadScheme) } return combinedErr diff --git a/receiver/elasticsearchreceiver/go.mod b/receiver/elasticsearchreceiver/go.mod index 5421a9c6a422..5e41cbe81e3e 100644 --- a/receiver/elasticsearchreceiver/go.mod +++ b/receiver/elasticsearchreceiver/go.mod @@ -22,7 +22,6 @@ require ( go.opentelemetry.io/otel/metric v1.26.0 go.opentelemetry.io/otel/trace v1.26.0 go.uber.org/goleak v1.3.0 - go.uber.org/multierr v1.11.0 go.uber.org/zap v1.27.0 ) @@ -98,6 +97,7 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.48.0 // indirect go.opentelemetry.io/otel/sdk v1.26.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.26.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/exp v0.0.0-20230711023510-fffb14384f22 // indirect golang.org/x/mod v0.16.0 // indirect golang.org/x/net v0.24.0 // indirect