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

feat(ottl): Add a new ottl trim function that trims leading and trailing whitespace from a string #36400

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rnishtala-sumo
Copy link
Contributor

@rnishtala-sumo rnishtala-sumo commented Nov 16, 2024

Description

A field test exists in an event, which contains the string " this is a test ".

I would like to be able to transform this using an ottl function trim, that I would define as trim(attribute["test"]), which would trim this down to "this is a test".

  • Trim(" this is a test ") results in this is a test

Link to the issue - #34100

Copy link
Member

@TylerHelmuth TylerHelmuth left a comment

Choose a reason for hiding this comment

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

Please add an entry to ottlfuncs/README for this new converter

@TylerHelmuth
Copy link
Member

@rnishtala-sumo can you add to the description the issue this PR closes

)

type TrimArguments[K any] struct {
Target ottl.StringGetter[K]
Copy link
Member

Choose a reason for hiding this comment

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

Lets add an optional parameter that allows specifying what to trim. I believe it should be a string and the converter will trim that string from both sides of the target string.

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.

4 participants