Open cmacknz opened 2 years ago
Pinging @elastic/elastic-agent-data-plane (Team:Elastic-Agent-Data-Plane)
@cmacknz I am right to assume that the first part of this issue is done but the second one is still pending?
Remove all uses of errors.Cause in the beats code. There are not that many of them so this is reasonable to do.
Yes that was done in https://github.com/elastic/beats/pull/31772
Shameless plug: you can switch it to drop-in replacement gitlab.com/tozd/go/errors
. It fixes many issues, is maintained, and supports modern Go's error patterns (sentinel errors, %w formatting, joined errors, etc.). It also provides some nice utility functions and structured details so that it is easy to extract dynamic data out of errors (instead of trying to get them out of formatted strings). Has improved error formatting and JSON marshaling of errors. It is interoperable with other errors packages and does not require a dependency on itself to extract data (e.g., stack trace) from errors.
The package is no longer maintained or recommended. It does not interact seamlessly with the error wrapping in the Go standard library.
Quoting a comment in a PR that originally proposed allowing use of the package again: https://github.com/elastic/beats/pull/31683#discussion_r877586230
We can make the following changes to facilitate moving away from github.com/pkg/errors:
errors.Cause
in the beats code. There are not that many of them so this is reasonable to do.github.com/pkg/errors
that passes through to the standard library but returnsnil
whennil
is passed toerrors.Wrap
to preserve the existing behaviour. Automated replacement ofgithub.com/pkg/errors
failed because of frequent use of this feature of theWrap
implementation. See the many failing tests in https://github.com/elastic/beats/pull/31622 for example.