open-telemetry / opentelemetry-collector-contrib

Contrib repository for the OpenTelemetry Collector
https://opentelemetry.io
Apache License 2.0
2.95k stars 2.29k forks source link

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

Open krokwen opened 4 months ago

krokwen commented 4 months ago

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

github-actions[bot] commented 4 months ago

Pinging code owners:

fede843 commented 3 months ago

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 https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/32895 https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/32896 mentioned above

github-actions[bot] commented 1 month ago

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

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