[pkg/stanza] Use HandleEntryError for error handling#35758
[pkg/stanza] Use HandleEntryError for error handling#35758khushijain21 wants to merge 24 commits into
Conversation
ChrsMark
left a comment
There was a problem hiding this comment.
Could we add some basic unit testing for this to ensure that the "mute" logic is preserved in the future?
Also I believe we should have a change-log entry (bug fix probably) for this since it affects what users see.
|
The API for parsers is a bit under-constrained but I think it would be cleaner to follow the pattern used in other parsers, where they move the parsing logic into an unexported function and then call that function using |
|
We already pass the parse method to the However the problem here is that we had to parse time after these calls in a custom func to avoid having to redefine the time Parser for each runtime. That's because the time parser is called after the parse function is called: |
|
Sure, but can't we push all parsing functionality into a single call to |
|
Hmm I think However, I think we can do the rest of the custom time parsing etc in a callback function which will be passed to |
|
Thanks for taking another look @ChrsMark. I'm a bit rusty on this part of the API so my suggestions are a bit off, but intuitively there must be a more normalized way than applying a special wrapper to every |
@djaglowski agreed! I think we can achieve this by moving the extra logic in a callback function passed to |
|
Hello, following the conversation, will this require code refactoring to avoid additional wrapper around each err? And if yes, can you direct how so? |
|
Hey @khushijain21 I believe my proposal would worth giving it a try. Unless @djaglowski has a different view. My proposal would be to move any additional logic that can produce unhandled errors into a callback function and then pass this function to ProcessWithCallback replacing with that the In this, the Note that Let me know if that makes sense. |
|
@ChrsMark, thanks, I think what you suggest makes sense. |
Co-authored-by: Christos Markou <chrismarkou92@gmail.com>
Co-authored-by: Christos Markou <chrismarkou92@gmail.com>
Co-authored-by: Christos Markou <chrismarkou92@gmail.com>
…llback (#35769) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Out of the discussions at #35758 I realized that `ProcessWithCallback` does not handle the error returned by the callback function. Since the error of the parse function is handled I think we should handle this of the callback too. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
|
@ChrsMark any update? |
|
Unit tests are failing now. I think that's because of the change in |
| } | ||
|
|
||
| if err = p.ParseWith(ctx, entry, parse); err != nil { | ||
| if p.OnError == DropOnErrorQuiet || p.OnError == SendOnErrorQuiet { |
There was a problem hiding this comment.
I'm not sure if we should discard the error here. This could lead to duplicating entries as described at #35973.
Otherwise, the container parser will get no error back and will further move the entry to the recombine parser.
| err = p.ParserOperator.ParseWithCallback(ctx, entry, p.parseContainerd, p.cbGoTimeLayout) | ||
| if err != nil { | ||
| return fmt.Errorf("failed to parse containerd log: %w", err) | ||
| return p.HandleEntryError(ctx, entry, stanzaerr.Wrap(err, "containerd log")) |
There was a problem hiding this comment.
Isn't the error already handled inside the ParseWithCallback? I would assume we should return nil here as the entry has already been either moved forward or dropped.
…ds (#36213) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This issue was caught at #35758. This PR ensures that time parsing happens before the entry is sent to the next operator in the pipeline. <!-- Issue number (e.g. #1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes ~ <!--Describe what testing was performed and which tests were added.--> #### Testing Added <!--Describe the documentation added.--> #### Documentation ~ <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
|
This PR was marked stale due to lack of activity. It will be closed in 14 days. |
…llback (open-telemetry#35769) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description Out of the discussions at open-telemetry#35758 I realized that `ProcessWithCallback` does not handle the error returned by the callback function. Since the error of the parse function is handled I think we should handle this of the callback too. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes <!--Describe what testing was performed and which tests were added.--> #### Testing <!--Describe the documentation added.--> #### Documentation <!--Please delete paragraphs that you did not use before submitting.--> --------- Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
…ds (open-telemetry#36213) <!--Ex. Fixing a bug - Describe the bug and how this fixes the issue. Ex. Adding a feature - Explain what this achieves.--> #### Description This issue was caught at open-telemetry#35758. This PR ensures that time parsing happens before the entry is sent to the next operator in the pipeline. <!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. --> #### Link to tracking issue Fixes ~ <!--Describe what testing was performed and which tests were added.--> #### Testing Added <!--Describe the documentation added.--> #### Documentation ~ <!--Please delete paragraphs that you did not use before submitting.--> Signed-off-by: ChrsMark <chrismarkou92@gmail.com>
Link to tracking issue
Fixes #35726
Uses
HandleEntryErrormethod to handle errors. More reasoning here