Skip to content

Conversation

@loewenheim
Copy link
Contributor

@loewenheim loewenheim commented Aug 28, 2025

This is an alternative to #5061.

Instead of hooking into scrubbing Attributes (via a new process_attributes method), we do it at the level of individual Attribute values (via a new process_attribute method). For common scrubbing rules, we just apply them to the attribute's value. For advanced scrubbing rules, we treat attributes as objects and delegate to their fields.

The differentiation between the two ways to treat attributes is controlled by a field attribute_mode of type AttributeMode on PiiProcessor. This decouples the logic from logs and makes it explicit what is happening.

TODO: Handle other in ValueOnly mode.

ref: #5096 ref: RELAY-152

Comment on lines -48 to +71
#[allow(clippy::needless_option_as_deref)]
for rule in rules {
let reborrowed_value = value.as_deref_mut();
apply_rule_to_value(meta, rule, state.path().key(), reborrowed_value)?;
apply_rule_to_value(meta, rule, state.path().key(), value.as_deref_mut())?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an incidental change.

},
},
"applications": {
"$log.attributes.remove_this_string_abc123.value": ["remove_abc123"],
Copy link
Contributor Author

@loewenheim loewenheim Aug 28, 2025

Choose a reason for hiding this comment

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

I believe this selector working on master is a bug. As I understand it a path starting with $log should not match the top-level object. The test_scrub_log_deep_wild_cards test below fails for a similar reason and is not so easily fixed.

Copy link
Member

Choose a reason for hiding this comment

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

As I understand it a path starting with $log should not match the top-level object

Why not? Don't we also have $minidump as a selector on the top level object?

@linear
Copy link

linear bot commented Aug 28, 2025

},
},
"applications": {
"$log.attributes.remove_this_string_abc123.value": ["remove_abc123"],
Copy link
Member

Choose a reason for hiding this comment

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

As I understand it a path starting with $log should not match the top-level object

Why not? Don't we also have $minidump as a selector on the top level object?

Comment on lines +228 to +239
match self.attribute_mode {
AttributeMode::Object => {
// Treat the attribute as an object and recurse into its children.
value.process_child_values(self, state)
}
AttributeMode::ValueOnly => {
// Identify the attribute with its value and apply rules there directly.
let value_state =
state.enter_nothing(Some(Cow::Owned(FieldAttrs::new().pii(Pii::True))));
processor::process_value(&mut value.value.value, self, &value_state)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Nice!

@loewenheim
Copy link
Contributor Author

Closing this in favor of #5112 and #5113. When trying to integrate relay-conventions into this I ran into insurmountable state management problems.

@loewenheim loewenheim closed this Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants