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

Add Unwrap methods to consumer errors #3069

Merged
merged 1 commit into from
Apr 30, 2021

Conversation

bjsignalfx
Copy link
Contributor

Description: Fixing a bug - Add Unwrap method to consumer errors permanent, Traces, Logs and Metrics. Functions Is and As in standard package errors use Unwrap to retrieve wrapped errors.

Testing: Created error type testErrorType. Wrapped testErrorType values with the consumer errors. Used function errors.As to retrieve wrapped testErrorType values. Added tests:

  • TestPermanent_Unwrap
  • TestTraces_Unwrap
  • TestLogs_Unwrap
  • TestMetrics_Unwrap

@bjsignalfx bjsignalfx requested a review from a team April 30, 2021 06:27
@tigrannajaryan
Copy link
Member

Why do we need this? Is this necessary for some other code that is blocked by this?

@bjsignalfx
Copy link
Contributor Author

Why do we need this? Is this necessary for some other code that is blocked by this?

I ran into a situation where consumererror.permanent is wrapped by consumererror.Logs and in that case IsPermanent() returns false because consumererror.Logs does not implement Unwrap. I also see that it may not make sense to wrap a permanent error with Logs, that is add failed logs to the permanent error, because it's not like you are going to retry sending. At the same time errors.As and errors.Is operations on consumer errors should work as expected.

@tigrannajaryan tigrannajaryan merged commit d2c3b2a into open-telemetry:main Apr 30, 2021
@bjsignalfx bjsignalfx deleted the consumererror-unwrap branch April 30, 2021 21:53
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