From bfcf5a0af8c1aecfe49adbe79a35e28345368aef Mon Sep 17 00:00:00 2001 From: shivanshu1333 Date: Mon, 14 Aug 2023 10:38:06 +0530 Subject: [PATCH] use errors.Join instead of go.uber.org/multierr --- receiver/scrapererror/scrapeerror.go | 4 ++-- receiver/scraperhelper/scrapercontroller.go | 3 +-- receiver/scraperhelper/scrapercontroller_test.go | 3 +-- receiver/scraperhelper/settings.go | 6 ++---- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/receiver/scrapererror/scrapeerror.go b/receiver/scrapererror/scrapeerror.go index 9c1b4b08a20..db1548ea55c 100644 --- a/receiver/scrapererror/scrapeerror.go +++ b/receiver/scrapererror/scrapeerror.go @@ -4,7 +4,7 @@ package scrapererror // import "go.opentelemetry.io/collector/receiver/scrapererror" import ( - "go.uber.org/multierr" + "errors" ) // ScrapeErrors contains multiple PartialScrapeErrors and can also contain generic errors. @@ -34,7 +34,7 @@ func (s *ScrapeErrors) Combine() error { } } - combined := multierr.Combine(s.errs...) + combined := errors.Join(s.errs...) if !partialScrapeErr { return combined } diff --git a/receiver/scraperhelper/scrapercontroller.go b/receiver/scraperhelper/scrapercontroller.go index 9f3dd0b5f86..e43bfbb2fe7 100644 --- a/receiver/scraperhelper/scrapercontroller.go +++ b/receiver/scraperhelper/scrapercontroller.go @@ -8,7 +8,6 @@ import ( "errors" "time" - "go.uber.org/multierr" "go.uber.org/zap" "go.opentelemetry.io/collector/component" @@ -146,7 +145,7 @@ func (sc *controller) Shutdown(ctx context.Context) error { var errs error for _, scraper := range sc.scrapers { - errs = multierr.Append(errs, scraper.Shutdown(ctx)) + errs = errors.Join(errs, scraper.Shutdown(ctx)) } return errs diff --git a/receiver/scraperhelper/scrapercontroller_test.go b/receiver/scraperhelper/scrapercontroller_test.go index 707f683cf97..4a6964667e7 100644 --- a/receiver/scraperhelper/scrapercontroller_test.go +++ b/receiver/scraperhelper/scrapercontroller_test.go @@ -13,7 +13,6 @@ import ( "github.com/stretchr/testify/require" "go.opentelemetry.io/otel/codes" sdktrace "go.opentelemetry.io/otel/sdk/trace" - "go.uber.org/multierr" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/component/componenttest" @@ -252,7 +251,7 @@ func getExpectedShutdownErr(test metricsTestCase) error { if test.closeErr != nil { for i := 0; i < test.scrapers; i++ { - errs = multierr.Append(errs, test.closeErr) + errs = errors.Join(errs, test.closeErr) } } diff --git a/receiver/scraperhelper/settings.go b/receiver/scraperhelper/settings.go index c59ea932583..00fa2a8d5bf 100644 --- a/receiver/scraperhelper/settings.go +++ b/receiver/scraperhelper/settings.go @@ -8,8 +8,6 @@ import ( "fmt" "time" - "go.uber.org/multierr" - "go.opentelemetry.io/collector/component" ) @@ -44,10 +42,10 @@ func NewDefaultScraperControllerSettings(component.Type) ScraperControllerSettin func (set *ScraperControllerSettings) Validate() (errs error) { if set.CollectionInterval <= 0 { - errs = multierr.Append(errs, fmt.Errorf(`"collection_interval": %w`, errNonPositiveInterval)) + errs = errors.Join(errs, fmt.Errorf(`"collection_interval": %w`, errNonPositiveInterval)) } if set.Timeout < 0 { - errs = multierr.Append(errs, fmt.Errorf(`"timeout": %w`, errNonPositiveInterval)) + errs = errors.Join(errs, fmt.Errorf(`"timeout": %w`, errNonPositiveInterval)) } return errs }