Skip to content

Conversation

@kinyoklion
Copy link
Member

@kinyoklion kinyoklion commented Mar 31, 2023

Implement a ContextFilter which allows for transforming a Context into filtered JSON suitable for events.

@kinyoklion kinyoklion changed the title feat: Change builder to allow for better loops. feat: Implement context filtering and JSON serialization. Mar 31, 2023
class Array {
public:
struct Iterator {
using iterator_category = std::forward_iterator_tag;
Copy link
Member Author

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) {
Copy link
Member Author

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.

// An item in an array cannot be marked private.
stack.push_back(StackItem{
*rev_from, std::vector<std::string_view>{}, *nested});
*rev_from++;
Copy link
Member Author

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)
Copy link
Member Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What part?

Copy link
Member Author

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.

@kinyoklion kinyoklion marked this pull request as ready for review March 31, 2023 21:43
@kinyoklion kinyoklion requested a review from cwaldren-ld March 31, 2023 21:46
* 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 {
Copy link
Member Author

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) {
Copy link
Member Author

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.

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.

4 participants