-
Notifications
You must be signed in to change notification settings - Fork 772
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
Examples: Fix ParentProvider not being set on MyFilteringProcessor #3370
Merged
CodeBlanch
merged 5 commits into
open-telemetry:main
from
CodeBlanch:example-filtering-processor-fix
Jun 16, 2022
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f965fa5
Fix ParentProvider not being set on MyFilteringProcessor example.
CodeBlanch 8473a05
Merge branch 'main' into example-filtering-processor-fix
CodeBlanch bd4ce45
Added XML comments.
CodeBlanch 7113fa0
Tweak.
CodeBlanch 5954cfa
Typo.
CodeBlanch 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 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Purely from the reader's perspective - I guess folks would question "why would I need to derive from CompositeProcessor?".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 this is a good question, and I can't think of simple explanation to give users. The alternative to making
SetParentProvider
public is problematic for similar reasons. I'd struggle to come up with a concise way to explain to users under what circumstances they need to be sure to callSetParentProvider
.In either case the explanation is basically: if you're newing up a processor and you're not directly passing it to
providerBuilder.AddProcessor()
(i.e., it's nested in another processor or something) then you gotta make sure that the parent provider gets set - which in turn ensures the processor has access to the configured resource... which may or may not be important depending on the processorwhich then raises questions of why the parent provider needs to be set, why does it need access to a resource, and when is all of this important
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a good solution for this! Agree with @alanwest exposing
SetParentProvider
feels wrong. I just added some XML comments explaining (or hinting at) what is going on in the example. That might help?We could introduce a class to make it more self-explanatory like...
...or...
I doubt anyone will like that either, but it's an option 🤣
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Giving this is an example, I guess I can just close my eyes on it and click the approve button. 🤣
I guess there might be a solution to retrieve the "parent" processor's ParentProvider - based on callstack or context (should be reasonably performant since we only have to fetch it once when the ParentProvider is not yet set), but maybe it's just an overkill 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea not yet excited about this idea. I do agree the naming offers a slight improvement, but I think it's worth sitting on a bit. Definitely think it's worth continuing this discussion in hopes of finding a better solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Something about this problem kinda feels similar to middleware branching. Like the filter processor effectively introduces a branch in the pipeline. Something like