Skip to content
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

Truncate Processor: Add support to truncate all fields in an event #4317

Merged
merged 3 commits into from
Mar 25, 2024

Conversation

kkondaka
Copy link
Collaborator

@kkondaka kkondaka commented Mar 21, 2024

Description

Supports truncating all fields in an event when source_keys is not specified or null.
The config would look like this to truncate all fields to a length of 5 characters.

processor:
   - truncate:
        entries:
           - length: 5

Also, added support to do truncation recursively in case of nested objects with config option

do_recursively: true

Issues Resolved

Resolves #[Issue number to be closed when this PR is merged]

Check List

  • [ X] New functionality includes testing.
  • New functionality has a documentation issue. Please link to it in this PR.
    • New functionality has javadoc added
  • [ X] Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

final int startIndex = entry.getStartAt() == null ? 0 : entry.getStartAt();
final Integer length = entry.getLength();
if (truncateWhen != null && !expressionEvaluator.evaluateConditional(truncateWhen, recordEvent)) {
continue;
}
boolean truncateAll = false;
for (String sourceKey : sourceKeys) {
if (sourceKey.equals("*")) {
Copy link
Member

Choose a reason for hiding this comment

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

This seems like we may be introducing a concept that could cause confusion. What if we change the behavior of source_keys to not require any input and make the default be all fields?

dlvenable
dlvenable previously approved these changes Mar 23, 2024
Copy link
Collaborator

@oeyh oeyh left a comment

Choose a reason for hiding this comment

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

Looks good! One minor comment below:

@@ -26,14 +24,18 @@ public static class Entry {
@JsonProperty("length")
private Integer length;

@JsonProperty("do_recursively")
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems a bit verbose, maybe "recursive" is clear enough?

Copy link
Member

Choose a reason for hiding this comment

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

@oeyh , I like that suggestion.

Signed-off-by: Krishna Kondaka <[email protected]>
@dlvenable dlvenable merged commit 8a7132d into opensearch-project:main Mar 25, 2024
43 of 47 checks passed
opensearch-trigger-bot bot pushed a commit that referenced this pull request Mar 25, 2024
…4317)

Truncate Processor: Add support to truncate all fields in an event

Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
(cherry picked from commit 8a7132d)
dlvenable pushed a commit that referenced this pull request Mar 26, 2024
…4317) (#4326)

Truncate Processor: Add support to truncate all fields in an event

Signed-off-by: Krishna Kondaka <[email protected]>
Co-authored-by: Krishna Kondaka <[email protected]>
(cherry picked from commit 8a7132d)

Co-authored-by: Krishna Kondaka <[email protected]>
@kkondaka kkondaka deleted the trancate-all branch May 13, 2024 05:51
@kkondaka kkondaka added this to the v2.8 milestone May 14, 2024
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