Skip to content

Commit

Permalink
Avoid using github.com/pkg/errors (open-telemetry#5535)
Browse files Browse the repository at this point in the history
Signed-off-by: Bogdan Drutu <bogdandrutu@gmail.com>
  • Loading branch information
bogdandrutu authored Oct 1, 2021
1 parent 338256e commit c4161db
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
4 changes: 2 additions & 2 deletions receiver/mongodbatlasreceiver/factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ package mongodbatlasreceiver

import (
"context"
"fmt"

"github.com/pkg/errors"
"go.opentelemetry.io/collector/component"
"go.opentelemetry.io/collector/config"
"go.opentelemetry.io/collector/consumer"
Expand Down Expand Up @@ -46,7 +46,7 @@ func createMetricsReceiver(
cfg := rConf.(*Config)
ms, err := newMongoDBAtlasReceiver(ctx, params.Logger, cfg, consumer)
if err != nil {
return nil, errors.Wrap(err, "Unable to create a MongoDB Atlas Receiver instance")
return nil, fmt.Errorf("unable to create a MongoDB Atlas Receiver instance: %w", err)
}
return ms, err
}
Expand Down
12 changes: 3 additions & 9 deletions receiver/mongodbatlasreceiver/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,11 @@ require (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/interval v0.36.0
go.mongodb.org/atlas v0.12.0
go.opentelemetry.io/collector v0.36.1-0.20210930151317-3ec4f1be6001
go.opentelemetry.io/collector/model v0.36.1-0.20210930151317-3ec4f1be6001 // indirect
go.uber.org/zap v1.19.1
golang.org/x/sys v0.0.0-20210902050250-f475640dd07b // indirect
)

require (
github.com/pkg/errors v0.9.1
go.opentelemetry.io/collector/model v0.36.1-0.20210930151317-3ec4f1be6001 // indirect
)

require (
github.com/fsnotify/fsnotify v1.4.9 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
Expand All @@ -27,6 +23,7 @@ require (
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/openlyinc/pointy v1.1.2 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/rogpeppe/go-internal v1.6.1 // indirect
github.com/spf13/cast v1.4.1 // indirect
go.opentelemetry.io/otel v1.0.0 // indirect
Expand All @@ -42,7 +39,4 @@ require (
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace (
github.com/open-telemetry/opentelemetry-collector-contrib/internal/common => ../../internal/common
github.com/open-telemetry/opentelemetry-collector-contrib/internal/interval => ../../internal/interval
)
replace github.com/open-telemetry/opentelemetry-collector-contrib/internal/interval => ../../internal/interval
10 changes: 5 additions & 5 deletions receiver/mongodbatlasreceiver/internal/mongodb_atlas_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ package internal

import (
"context"
"fmt"

"github.com/mongodb-forks/digest"
"github.com/pkg/errors"
"go.mongodb.org/atlas/mongodbatlas"
"go.uber.org/zap"
)

// This struct wraps the official MongoDB Atlas client to manage pagination
// MongoDBAtlasClient wraps the official MongoDB Atlas client to manage pagination
// and mapping to OpenTelmetry metric and log structures.
type MongoDBAtlasClient struct {
log *zap.Logger
Expand All @@ -38,7 +38,7 @@ func NewMongoDBAtlasClient(
t := digest.NewTransport(publicKey, privateKey)
tc, err := t.Client()
if err != nil {
return nil, errors.Wrap(err, "Could not create MongoDB Atlas transport HTTP client")
return nil, fmt.Errorf("could not create MongoDB Atlas transport HTTP client: %w", err)
}
client := mongodbatlas.NewClient(tc)
return &MongoDBAtlasClient{
Expand Down Expand Up @@ -67,7 +67,7 @@ func hasNext(links []*mongodbatlas.Link) bool {
return false
}

// Return a list of all organizations available with the supplied credentials
// Organizations returns a list of all organizations available with the supplied credentials
func (s *MongoDBAtlasClient) Organizations(ctx context.Context) []*mongodbatlas.Organization {
allOrgs := make([]*mongodbatlas.Organization, 0)
page := 1
Expand Down Expand Up @@ -99,7 +99,7 @@ func (s *MongoDBAtlasClient) getOrganizationsPage(
})
err = checkMongoDBClientErr(err, response)
if err != nil {
return nil, false, errors.Wrap(err, "Error in retrieving organizations")
return nil, false, fmt.Errorf("error in retrieving organizations: %w", err)
}
return orgs.Results, hasNext(orgs.Links), nil
}

0 comments on commit c4161db

Please sign in to comment.