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

[pkg/ottl] Split ConvertCase function to explicit functions for each case #32942

Open
krokwen opened this issue May 8, 2024 · 2 comments
Open
Labels
enhancement New feature or request needs triage New item requiring triage pkg/ottl

Comments

@krokwen
Copy link

krokwen commented May 8, 2024

Component(s)

pkg/ottl

Is your feature request related to a problem? Please describe.

ConvertCase function accepts StringGetter first argument and could be used as converting function in functions like replace_all_patterns, but it requires the second argument, that makes impossible to use it in such case

Describe the solution you'd like

ToLowerCase("String") instead of ConvertCase("String", "lower")
ToUpperCase("String") instead of ConvertCase("String", "upper")
ToSnakeCase("String") instead of ConvertCase("String", "snake")
ToCamelCase("String") instead of ConvertCase("String", "camel")

Describe alternatives you've considered

No response

Additional context

Currently (using a bug, #32895 #32896) I use a SHA1 function with replace_all_patterns as fastest available option to convert the value under matching key, but i believe, case converting will be much faster, please correct me if i'm wrong

@krokwen krokwen added enhancement New feature or request needs triage New item requiring triage labels May 8, 2024
Copy link
Contributor

github-actions bot commented May 8, 2024

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@fede843
Copy link

fede843 commented Jun 18, 2024

Hi, ended up here looking for something like:

  `replace_all_patterns(attributes, "key", "http.request.header.(.+)", "$0", ConvertCase)`,

I actually would like to set those attributes all to lowercase. Since ConvertCase has an extra arg I cannot do it.
I have also noticed, for sake of testing, that even with SHA1 as function, that changed the value. I would have expected the key to be replaced. Related to #32895 #32896 mentioned above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs triage New item requiring triage pkg/ottl
Projects
None yet
Development

No branches or pull requests

2 participants