Skip to content

Commit

Permalink
[receiver/elasticsearch] remove multierr from elasticsearch receiver (#…
Browse files Browse the repository at this point in the history
…33052)

**Description:** <Describe what has changed.>
Replace multierr in favor of errors.Join

**Link to tracking Issue:** 

#25121

**Testing:** <Describe what testing was performed and which tests were
added.>

**Documentation:** <Describe the documentation added.>
  • Loading branch information
rogercoll authored May 16, 2024
1 parent 34a5a27 commit 4b9a237
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions receiver/elasticsearchreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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),
)
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion receiver/elasticsearchreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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/crypto v0.23.0 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.25.0 // indirect
Expand Down

0 comments on commit 4b9a237

Please sign in to comment.