From e136bfdee5c1605029276ca9b9fd2434ca08fcdf Mon Sep 17 00:00:00 2001 From: Shivanshu Raj Shrivastava Date: Mon, 14 Aug 2023 18:05:13 +0530 Subject: [PATCH] [chore] Migrate all `aws` receviers to use errors.Join (#25185) Related to https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/25121 --- receiver/awscloudwatchmetricsreceiver/config.go | 6 ++---- receiver/awscloudwatchmetricsreceiver/go.mod | 2 +- receiver/awscloudwatchreceiver/config.go | 3 +-- receiver/awscloudwatchreceiver/go.mod | 2 +- receiver/awscloudwatchreceiver/logs.go | 4 ++-- receiver/awscontainerinsightreceiver/go.mod | 2 +- .../internal/cadvisor/cadvisor_linux.go | 5 ++--- .../awscontainerinsightreceiver/internal/stores/podstore.go | 3 +-- receiver/awscontainerinsightreceiver/receiver.go | 5 ++--- receiver/awsxrayreceiver/go.mod | 2 +- receiver/awsxrayreceiver/receiver.go | 4 ++-- 11 files changed, 16 insertions(+), 22 deletions(-) diff --git a/receiver/awscloudwatchmetricsreceiver/config.go b/receiver/awscloudwatchmetricsreceiver/config.go index 516dedcf7592..67776872166b 100644 --- a/receiver/awscloudwatchmetricsreceiver/config.go +++ b/receiver/awscloudwatchmetricsreceiver/config.go @@ -9,8 +9,6 @@ import ( "net/url" "strings" "time" - - "go.uber.org/multierr" ) var ( @@ -78,7 +76,7 @@ func (cfg *Config) Validate() error { return errInvalidPollInterval } var errs error - errs = multierr.Append(errs, cfg.validateMetricsConfig()) + errs = errors.Join(errs, cfg.validateMetricsConfig()) return errs } @@ -111,7 +109,7 @@ func (cfg *Config) validateDimensionsConfig() error { if name.MetricName == "" { return errNoMetricsConfigured } - errs = multierr.Append(errs, validate(name.Dimensions)) + errs = errors.Join(errs, validate(name.Dimensions)) } return errs } diff --git a/receiver/awscloudwatchmetricsreceiver/go.mod b/receiver/awscloudwatchmetricsreceiver/go.mod index c702fd72caea..a5439d67913c 100644 --- a/receiver/awscloudwatchmetricsreceiver/go.mod +++ b/receiver/awscloudwatchmetricsreceiver/go.mod @@ -7,7 +7,6 @@ require ( go.opentelemetry.io/collector/component v0.82.0 go.opentelemetry.io/collector/consumer v0.82.0 go.opentelemetry.io/collector/receiver v0.82.0 - go.uber.org/multierr v1.11.0 go.uber.org/zap v1.25.0 ) @@ -31,6 +30,7 @@ require ( go.opentelemetry.io/otel v1.16.0 // indirect go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect diff --git a/receiver/awscloudwatchreceiver/config.go b/receiver/awscloudwatchreceiver/config.go index 0120cf4be091..34fbbf50db9f 100644 --- a/receiver/awscloudwatchreceiver/config.go +++ b/receiver/awscloudwatchreceiver/config.go @@ -10,7 +10,6 @@ import ( "time" "go.opentelemetry.io/collector/confmap" - "go.uber.org/multierr" ) var ( @@ -76,7 +75,7 @@ func (c *Config) Validate() error { } var errs error - errs = multierr.Append(errs, c.validateLogsConfig()) + errs = errors.Join(errs, c.validateLogsConfig()) return errs } diff --git a/receiver/awscloudwatchreceiver/go.mod b/receiver/awscloudwatchreceiver/go.mod index 22a516122152..cb58897c2369 100644 --- a/receiver/awscloudwatchreceiver/go.mod +++ b/receiver/awscloudwatchreceiver/go.mod @@ -12,7 +12,6 @@ require ( go.opentelemetry.io/collector/consumer v0.82.0 go.opentelemetry.io/collector/pdata v1.0.0-rcv0014 go.opentelemetry.io/collector/receiver v0.82.0 - go.uber.org/multierr v1.11.0 go.uber.org/zap v1.25.0 ) @@ -38,6 +37,7 @@ require ( go.opentelemetry.io/otel v1.16.0 // indirect go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect diff --git a/receiver/awscloudwatchreceiver/logs.go b/receiver/awscloudwatchreceiver/logs.go index 16f1ead9f0bc..c0f2a85e6469 100644 --- a/receiver/awscloudwatchreceiver/logs.go +++ b/receiver/awscloudwatchreceiver/logs.go @@ -5,6 +5,7 @@ package awscloudwatchreceiver // import "github.com/open-telemetry/opentelemetry import ( "context" + "errors" "fmt" "sync" "time" @@ -17,7 +18,6 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/pdata/pcommon" "go.opentelemetry.io/collector/pdata/plog" - "go.uber.org/multierr" "go.uber.org/zap" ) @@ -182,7 +182,7 @@ func (l *logsReceiver) poll(ctx context.Context) error { endTime := time.Now() for _, r := range l.groupRequests { if err := l.pollForLogs(ctx, r, startTime, endTime); err != nil { - errs = multierr.Append(errs, err) + errs = errors.Join(errs, err) } } l.nextStartTime = endTime diff --git a/receiver/awscontainerinsightreceiver/go.mod b/receiver/awscontainerinsightreceiver/go.mod index 86f9d69f3793..a0b017a1f891 100644 --- a/receiver/awscontainerinsightreceiver/go.mod +++ b/receiver/awscontainerinsightreceiver/go.mod @@ -19,7 +19,6 @@ require ( go.opentelemetry.io/collector/consumer v0.82.0 go.opentelemetry.io/collector/pdata v1.0.0-rcv0014 go.opentelemetry.io/collector/receiver v0.82.0 - go.uber.org/multierr v1.11.0 go.uber.org/zap v1.25.0 k8s.io/api v0.27.4 k8s.io/apimachinery v0.27.4 @@ -121,6 +120,7 @@ require ( go.opentelemetry.io/otel v1.16.0 // indirect go.opentelemetry.io/otel/metric v1.16.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/oauth2 v0.11.0 // indirect golang.org/x/sys v0.11.0 // indirect diff --git a/receiver/awscontainerinsightreceiver/internal/cadvisor/cadvisor_linux.go b/receiver/awscontainerinsightreceiver/internal/cadvisor/cadvisor_linux.go index cd3b022b865f..7411bf6cd12b 100644 --- a/receiver/awscontainerinsightreceiver/internal/cadvisor/cadvisor_linux.go +++ b/receiver/awscontainerinsightreceiver/internal/cadvisor/cadvisor_linux.go @@ -23,7 +23,6 @@ import ( "github.com/google/cadvisor/manager" "github.com/google/cadvisor/utils/sysfs" "go.opentelemetry.io/collector/pdata/pmetric" - "go.uber.org/multierr" "go.uber.org/zap" ci "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight" @@ -169,11 +168,11 @@ func GetMetricsExtractors() []extractors.MetricExtractor { func (c *Cadvisor) Shutdown() error { var errs error for _, ext := range metricsExtractors { - errs = multierr.Append(errs, ext.Shutdown()) + errs = errors.Join(errs, ext.Shutdown()) } if c.k8sDecorator != nil { - errs = multierr.Append(errs, c.k8sDecorator.Shutdown()) + errs = errors.Join(errs, c.k8sDecorator.Shutdown()) } return errs } diff --git a/receiver/awscontainerinsightreceiver/internal/stores/podstore.go b/receiver/awscontainerinsightreceiver/internal/stores/podstore.go index 0fca19d55498..9c587f9564f1 100644 --- a/receiver/awscontainerinsightreceiver/internal/stores/podstore.go +++ b/receiver/awscontainerinsightreceiver/internal/stores/podstore.go @@ -13,7 +13,6 @@ import ( "sync" "time" - "go.uber.org/multierr" "go.uber.org/zap" corev1 "k8s.io/api/core/v1" @@ -141,7 +140,7 @@ func (p *PodStore) Shutdown() error { errs = p.cache.Shutdown() for _, maps := range p.prevMeasurements { if prevMeasErr := maps.Shutdown(); prevMeasErr != nil { - errs = multierr.Append(errs, prevMeasErr) + errs = errors.Join(errs, prevMeasErr) } } return errs diff --git a/receiver/awscontainerinsightreceiver/receiver.go b/receiver/awscontainerinsightreceiver/receiver.go index fbde4b19c7f0..d192977a1341 100644 --- a/receiver/awscontainerinsightreceiver/receiver.go +++ b/receiver/awscontainerinsightreceiver/receiver.go @@ -12,7 +12,6 @@ import ( "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/pdata/pmetric" "go.opentelemetry.io/collector/receiver" - "go.uber.org/multierr" "go.uber.org/zap" ci "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/containerinsight" @@ -131,10 +130,10 @@ func (acir *awsContainerInsightReceiver) Shutdown(context.Context) error { var errs error if acir.k8sapiserver != nil { - errs = multierr.Append(errs, acir.k8sapiserver.Shutdown()) + errs = errors.Join(errs, acir.k8sapiserver.Shutdown()) } if acir.cadvisor != nil { - errs = multierr.Append(errs, acir.cadvisor.Shutdown()) + errs = errors.Join(errs, acir.cadvisor.Shutdown()) } return errs diff --git a/receiver/awsxrayreceiver/go.mod b/receiver/awsxrayreceiver/go.mod index cf5cead89ec7..03f93ff0f025 100644 --- a/receiver/awsxrayreceiver/go.mod +++ b/receiver/awsxrayreceiver/go.mod @@ -21,7 +21,6 @@ require ( go.opentelemetry.io/collector/pdata v1.0.0-rcv0014 go.opentelemetry.io/collector/receiver v0.82.0 go.opentelemetry.io/collector/semconv v0.82.0 - go.uber.org/multierr v1.11.0 go.uber.org/zap v1.25.0 ) @@ -68,6 +67,7 @@ require ( go.opentelemetry.io/otel/sdk v1.16.0 // indirect go.opentelemetry.io/otel/sdk/metric v0.39.0 // indirect go.opentelemetry.io/otel/trace v1.16.0 // indirect + go.uber.org/multierr v1.11.0 // indirect golang.org/x/net v0.14.0 // indirect golang.org/x/sys v0.11.0 // indirect golang.org/x/text v0.12.0 // indirect diff --git a/receiver/awsxrayreceiver/receiver.go b/receiver/awsxrayreceiver/receiver.go index d815c2e54535..458e81c1dd7f 100644 --- a/receiver/awsxrayreceiver/receiver.go +++ b/receiver/awsxrayreceiver/receiver.go @@ -5,13 +5,13 @@ package awsxrayreceiver // import "github.com/open-telemetry/opentelemetry-colle import ( "context" + "errors" "fmt" "go.opentelemetry.io/collector/component" "go.opentelemetry.io/collector/consumer" "go.opentelemetry.io/collector/obsreport" "go.opentelemetry.io/collector/receiver" - "go.uber.org/multierr" "go.uber.org/zap" "github.com/open-telemetry/opentelemetry-collector-contrib/internal/aws/proxy" @@ -102,7 +102,7 @@ func (x *xrayReceiver) Shutdown(ctx context.Context) error { } if proxyErr := x.server.Shutdown(ctx); proxyErr != nil { - err = multierr.Append(err, fmt.Errorf("failed to close proxy: %w", proxyErr)) + err = errors.Join(err, fmt.Errorf("failed to close proxy: %w", proxyErr)) } return err }