Skip to content

Commit

Permalink
use errors.Join instead of go.uber.org/multierr
Browse files Browse the repository at this point in the history
  • Loading branch information
shivanshuraj1333 committed Aug 14, 2023
1 parent 07db6e6 commit bdf4564
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 22 deletions.
6 changes: 2 additions & 4 deletions receiver/awscloudwatchmetricsreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import (
"net/url"
"strings"
"time"

"go.uber.org/multierr"
)

var (
Expand Down Expand Up @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion receiver/awscloudwatchmetricsreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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
Expand Down
3 changes: 1 addition & 2 deletions receiver/awscloudwatchreceiver/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"time"

"go.opentelemetry.io/collector/confmap"
"go.uber.org/multierr"
)

var (
Expand Down Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion receiver/awscloudwatchreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions receiver/awscloudwatchreceiver/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package awscloudwatchreceiver // import "github.com/open-telemetry/opentelemetry

import (
"context"
"errors"
"fmt"
"sync"
"time"
Expand All @@ -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"
)

Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion receiver/awscontainerinsightreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"sync"
"time"

"go.uber.org/multierr"
"go.uber.org/zap"
corev1 "k8s.io/api/core/v1"

Expand Down Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions receiver/awscontainerinsightreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion receiver/awsxrayreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions receiver/awsxrayreceiver/receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit bdf4564

Please sign in to comment.