Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace pkg/errors wrapping with fmt.Errorf #2070

Merged
merged 1 commit into from
Feb 17, 2020

Conversation

u5surf
Copy link
Contributor

@u5surf u5surf commented Feb 13, 2020

Which problem is this PR solving?

Short description of the changes

  • I replaced error.wrapping using fmt.Errorf

@@ -182,7 +181,7 @@ func (fakeCollectorProxy) EmitBatch(batch *jaeger.Batch) (err error) {
}

func (f fakeCollectorProxy) GetSamplingStrategy(serviceName string) (*sampling.SamplingStrategyResponse, error) {
return nil, errors.New("no peers available")
return nil, fmt.Errorf("no peers available")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's no need to change this

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are many unnecessary changes here. The intention was to remove the use of "github.com/pkg/errors", but there's nothing wrong with using the standard errors.New().

To ensure that "github.com/pkg/errors" is gone, we should remove it from Gopkg.toml

@codecov
Copy link

codecov bot commented Feb 13, 2020

Codecov Report

Merging #2070 into master will increase coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2070   +/-   ##
=======================================
  Coverage   96.38%   96.38%           
=======================================
  Files         214      214           
  Lines       10525    10529    +4     
=======================================
+ Hits        10144    10148    +4     
  Misses        325      325           
  Partials       56       56           
Impacted Files Coverage Δ
cmd/collector/app/metrics.go 100.00% <0.00%> (ø) ⬆️
cmd/collector/app/options.go 100.00% <0.00%> (ø) ⬆️
cmd/collector/app/span_processor.go 100.00% <0.00%> (ø) ⬆️
cmd/collector/app/zipkin/http_handler.go 100.00% <0.00%> (ø) ⬆️
cmd/collector/app/builder_flags.go 100.00% <0.00%> (ø) ⬆️
cmd/collector/app/handler/grpc_handler.go 100.00% <0.00%> (ø) ⬆️
cmd/collector/app/handler/tchannel_handler.go 100.00% <0.00%> (ø) ⬆️
pkg/normalizer/service_name.go 100.00% <0.00%> (ø) ⬆️
cmd/collector/app/handler/http_handler.go 100.00% <0.00%> (ø) ⬆️
cmd/collector/app/handler/thrift_span_handler.go 94.73% <0.00%> (ø) ⬆️
... and 1 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3ae21ef...c8b5f80. Read the comment docs.

@u5surf
Copy link
Contributor Author

u5surf commented Feb 13, 2020

There are many unnecessary changes here. The intention was to remove the use of "github.com/pkg/errors", but there's nothing wrong with using the standard errors.New().

To ensure that "github.com/pkg/errors" is gone, we should remove it from Gopkg.toml

copied

@u5surf
Copy link
Contributor Author

u5surf commented Feb 14, 2020

@yurishkuro
I replaced github.com/pkg/errors with native libraries.
then I confirmed following make lint error. It is easy to resolve this error, but some error messages will be changed the non capitalized starting. May I fix all of them?

$ make lint
time staticcheck ./... \
        | grep -v \
                -e model/model.pb.go \
                -e thrift-gen/ \
        >> .lint.log || true

real    0m14.487s
user    0m18.184s
sys     0m2.832s
Detected staticcheck failures:
cmd/agent/app/reporter/grpc/collector_proxy.go:24:2: package "github.com/jaegertracing/jaeger/cmd/agent/app/reporter" is being imported more than once (ST1019)
        cmd/agent/app/reporter/grpc/collector_proxy.go:25:2: other import of "github.com/jaegertracing/jaeger/cmd/agent/app/reporter"
pkg/es/config/config.go:90:15: error strings should not be capitalized (ST1005)
pkg/kafka/auth/config.go:66:10: error strings should not end with punctuation or a newline (ST1005)
plugin/storage/badger/dependencystore/storage_test.go:83:21: unnecessary use of fmt.Sprintf (S1039)
plugin/storage/badger/spanstore/read_write_test.go:430:19: unnecessary use of fmt.Sprintf (S1039)
plugin/storage/badger/spanstore/read_write_test.go:432:18: unnecessary use of fmt.Sprintf (S1039)
plugin/storage/cassandra/spanstore/reader.go:75:25: error strings should not be capitalized (ST1005)
plugin/storage/cassandra/spanstore/reader.go:78:34: error strings should not be capitalized (ST1005)
plugin/storage/cassandra/spanstore/reader.go:81:33: error strings should not be capitalized (ST1005)
plugin/storage/cassandra/spanstore/reader.go:84:30: error strings should not be capitalized (ST1005)
plugin/storage/cassandra/spanstore/reader.go:87:39: error strings should not be capitalized (ST1005)
plugin/storage/cassandra/spanstore/reader.go:90:29: error strings should not be capitalized (ST1005)
plugin/storage/es/dependencystore/storage.go:103:16: error strings should not be capitalized (ST1005)
plugin/storage/es/spanstore/reader.go:67:25: error strings should not be capitalized (ST1005)
plugin/storage/es/spanstore/reader.go:70:34: error strings should not be capitalized (ST1005)
plugin/storage/es/spanstore/reader.go:73:33: error strings should not be capitalized (ST1005)
plugin/storage/es/spanstore/reader.go:76:30: error strings should not be capitalized (ST1005)
plugin/storage/es/spanstore/reader.go:79:29: error strings should not be capitalized (ST1005)
plugin/storage/es/spanstore/reader.go:82:38: error strings should not be capitalized (ST1005)
plugin/storage/es/spanstore/reader.go:277:16: error strings should not be capitalized (ST1005)
plugin/storage/es/spanstore/service_operation.go:97:15: error strings should not be capitalized (ST1005)
plugin/storage/es/spanstore/service_operation.go:128:15: error strings should not be capitalized (ST1005)
make: *** [lint-staticcheck] error 1

@yurishkuro
Copy link
Member

it's ok to change capitalization. but first please see my comment https://github.com/jaegertracing/jaeger/pull/2070/files#r378924852 - you're making too many unnecessary changes by replacing "errors" with "fmt", which is not in scope of this ticket.

@u5surf u5surf force-pushed the issue-2061 branch 2 times, most recently from 86c43b7 to 6211b43 Compare February 14, 2020 16:06
Gopkg.toml Outdated
[[constraint]]
name = "github.com/pkg/errors"
version = "^0.8.0"

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make sure to run dep ensure --update to reflect this change in the lock file.

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks great, almost there!

if err != nil {
err = fmt.Errorf("unable to parse %s: %w", endTimeParam, err)
}
if aH.handleError(w, err, http.StatusBadRequest) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handleError already checks for the error, so these two ifs are redundant. The simplest fix is

if err != nil {
    aH.handleError(w, fmt.Errorf("unable to parse %s: %w", endTimeParam, err), http.StatusBadRequest)
    return
}

@@ -87,14 +87,14 @@ func (s *ServiceOperationStorage) getServices(context context.Context, indices [

searchResult, err := searchService.Do(context)
if err != nil {
return nil, errors.Wrap(err, "Search service failed")
return nil, fmt.Errorf("search service failed: %w", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: search for services failed

@@ -118,14 +118,14 @@ func (s *ServiceOperationStorage) getOperations(context context.Context, indices

searchResult, err := searchService.Do(context)
if err != nil {
return nil, errors.Wrap(err, "Search service failed")
return nil, fmt.Errorf("search service failed: %w", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: search for operations failed

@u5surf u5surf force-pushed the issue-2061 branch 2 times, most recently from d2c9e42 to 9d05996 Compare February 16, 2020 23:56
@yurishkuro
Copy link
Member

The linter is breaking due to upgrade of grpc. I am adjusting the deps separately in #2072.

@yurishkuro
Copy link
Member

NB: you may want to undo the Gopkg.* changes, because pkg/errors is still a transitive dependency, and not having to touch deps will make this PR less complicated.

@u5surf
Copy link
Contributor Author

u5surf commented Feb 17, 2020

@yurishkuro Certainly, Gopkg.* reverted.

@yurishkuro yurishkuro merged commit f3df4ef into jaegertracing:master Feb 17, 2020
@yurishkuro
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants