-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Implement context filtering and JSON serialization. #11
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
Conversation
| class Array { | ||
| public: | ||
| struct Iterator { | ||
| using iterator_category = std::forward_iterator_tag; |
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.
So we can iterate the array either direction.
| std::vector<std::string> redactions; | ||
|
|
||
| filtered.as_object().emplace("key", attributes.key()); | ||
| if (include_kind) { |
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.
Conditional for single versus multi-context.
libs/common/src/context_filter.cpp
Outdated
| // An item in an array cannot be marked private. | ||
| stack.push_back(StackItem{ | ||
| *rev_from, std::vector<std::string_view>{}, *nested}); | ||
| *rev_from++; |
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 disagree clang.
|
|
||
| ContextFilter::ContextFilter( | ||
| bool all_attributes_private, | ||
| AttributeReference::SetType const& global_private_attributes) |
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 am again considering if these should be shared pointers.
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.
What part?
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.
Instead of references to global_private_attributes a shared pointer to them. Makes lifetime management easier to have a smart pointer.
| * added to the output object. If the node is complex, then each of its | ||
| * immediately children is added to the stack to be processed. | ||
| */ | ||
| struct StackItem { |
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 generally try to avoid recursive implementations outside functional languages. I have done that here, but I have not specifically benchmarked and compared the stack size and performance between the two implementations.
| return filtered; | ||
| } | ||
|
|
||
| void ContextFilter::append_simple_type(ContextFilter::StackItem& item) { |
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.
It is possible some of this code may be replaced when I add more JSON support around values.
Implement a ContextFilter which allows for transforming a Context into filtered JSON suitable for events.