-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Tidy up consumer/consumererror package.
#2768
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
Merged
bogdandrutu
merged 6 commits into
open-telemetry:main
from
Aneurysm9:consumererror_tidy
Mar 23, 2021
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
bbd5139
Tidy up `consumer/consumererror` package.
Aneurysm9 6c8470a
Rename consumererror signal error types to align with rest of codebase
Aneurysm9 e9cb93a
Rename `onPartialError` to `onError` in `exporterhelper.request` inte…
Aneurysm9 2a2aa5e
Provide conversion methods to consumererror signal error types.
Aneurysm9 3f37d32
Avoid unnecessary allocation, fixup docs
Aneurysm9 ebd3673
Merge branch 'main' of github.com:open-telemetry/opentelemetry-collec…
Aneurysm9 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| // Copyright The OpenTelemetry Authors | ||
| // | ||
| // Licensed under the Apache License, Version 2.0 (the "License"); | ||
| // you may not use this file except in compliance with the License. | ||
| // You may obtain a copy of the License at | ||
| // | ||
| // http://www.apache.org/licenses/LICENSE-2.0 | ||
| // | ||
| // Unless required by applicable law or agreed to in writing, software | ||
| // distributed under the License is distributed on an "AS IS" BASIS, | ||
| // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| // See the License for the specific language governing permissions and | ||
| // limitations under the License. | ||
|
|
||
| package consumererror | ||
|
|
||
| import ( | ||
| "errors" | ||
|
|
||
| "go.opentelemetry.io/collector/consumer/pdata" | ||
| ) | ||
|
|
||
| // Traces is an error that may carry associated Trace data for a subset of received data | ||
| // that faiiled to be processed or sent. | ||
| type Traces struct { | ||
| error | ||
| failed pdata.Traces | ||
| } | ||
|
|
||
| // NewTraces creates a Traces that can encapsulate received data that failed to be processed or sent. | ||
| func NewTraces(err error, failed pdata.Traces) error { | ||
| return Traces{ | ||
| error: err, | ||
| failed: failed, | ||
| } | ||
| } | ||
|
|
||
| // AsTraces finds the first error in err's chain that can be assigned to target. If such an error is found | ||
| // it is assigned to target and true is returned, otherwise false is returned. | ||
| func AsTraces(err error, target *Traces) bool { | ||
| if err == nil { | ||
| return false | ||
| } | ||
| return errors.As(err, target) | ||
| } | ||
|
|
||
| // GetTraces returns failed traces from the associated error. | ||
| func (err Traces) GetTraces() pdata.Traces { | ||
| return err.failed | ||
| } | ||
|
|
||
| // Logs is an error that may carry associated Log data for a subset of received data | ||
| // that faiiled to be processed or sent. | ||
| type Logs struct { | ||
| error | ||
| failed pdata.Logs | ||
| } | ||
|
|
||
| // NewLogs creates a Logs that can encapsulate received data that failed to be processed or sent. | ||
| func NewLogs(err error, failed pdata.Logs) error { | ||
| return Logs{ | ||
| error: err, | ||
| failed: failed, | ||
| } | ||
| } | ||
|
|
||
| // AsLogs finds the first error in err's chain that can be assigned to target. If such an error is found | ||
| // it is assigned to target and true is returned, otherwise false is returned. | ||
| func AsLogs(err error, target *Logs) bool { | ||
| if err == nil { | ||
| return false | ||
| } | ||
| return errors.As(err, target) | ||
| } | ||
|
|
||
| // GetLogs returns failed logs from the associated error. | ||
| func (err Logs) GetLogs() pdata.Logs { | ||
| return err.failed | ||
| } | ||
|
|
||
| // Metrics is an error that may carry associated Metrics data for a subset of received data | ||
| // that faiiled to be processed or sent. | ||
| type Metrics struct { | ||
| error | ||
| failed pdata.Metrics | ||
| } | ||
|
|
||
| // NewMetrics creates a Metrics that can encapsulate received data that failed to be processed or sent. | ||
| func NewMetrics(err error, failed pdata.Metrics) error { | ||
| return Metrics{ | ||
| error: err, | ||
| failed: failed, | ||
| } | ||
| } | ||
|
|
||
| // AsMetrics finds the first error in err's chain that can be assigned to target. If such an error is found | ||
| // it is assigned to target and true is returned, otherwise false is returned. | ||
| func AsMetrics(err error, target *Metrics) bool { | ||
| if err == nil { | ||
| return false | ||
| } | ||
| return errors.As(err, target) | ||
| } | ||
|
|
||
| // GetMetrics returns failed metrics from the associated error. | ||
| func (err Metrics) GetMetrics() pdata.Metrics { | ||
| return err.failed | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.