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

OTTL ConvertCase for dot.delimited.case #18084

Closed
seankhliao opened this issue Jan 28, 2023 · 17 comments
Closed

OTTL ConvertCase for dot.delimited.case #18084

seankhliao opened this issue Jan 28, 2023 · 17 comments
Labels
closed as inactive enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed pkg/ottl Stale

Comments

@seankhliao
Copy link
Contributor

Component(s)

pkg/ottl

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

I'd like to convert metric/attribute names into a standardized form of dot.delimited.names

Describe the solution you'd like

ConvertCase learns a new toCase value of dot

Describe alternatives you've considered

replace_all_* functions only work on maps, not a string as required for changing the metric name.

Additional context

No response

@seankhliao seankhliao added enhancement New feature or request needs triage New item requiring triage labels Jan 28, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

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

@TylerHelmuth
Copy link
Member

TylerHelmuth commented Jan 28, 2023

@seankhliao Would replace_pattern or replace_match work for you?

@seankhliao
Copy link
Contributor Author

I skipped over it thinking it was a single match variant

I think it only works if combined with converting to snake case first, ConvertCase will handle acronyms which is difficult to replicate in regex

eg namespaced_PRCount -> namespaced.pr.count

@seankhliao
Copy link
Contributor Author

I sent in #18275 for the case I raised here (dot).

Though I'm wondering if ConvertCase would be better served by being more general:
if the toCase argument is a single character, use that as the delimiter, otherwise fall back to the well known ones (upper and lower).
This would help with systems that use other delimiters, eg GCP conventions appear to be / separated

@TylerHelmuth
Copy link
Member

@seankhliao you raise an interesting point. I certainly don't want to keep adding new cases for each character that someone wants to delimit with. I think it would be good to expose ToDelimited's capability somehow.

A couple ideas:

  1. At the moment OTTL purposefully does not do optional parameters. We could add a third parameter that is not used for established named cases such as upper, lower, camel, and snake (although I think snake could be covered via ToDelimiter("_")). But that is kinda messy for named cases.
  2. As you mentioned, we could use the toCase parameter as a delimiter if it is a single character, otherwise fall back to known patterns. If none are matched, error. The parameter feels overloaded with this idea, but it helps deal with a third param and a breaking change.
  3. We could expose ToDelimited via a separate function. But it'd be sooo similar to convert case :/.
  4. We could also just suck it up and add new cases for different delimiting character.

I think before we merge in your PR we should come to a conclusion on this. @evan-bradley @bogdandrutu what do you think? I lean towards @seankhliao's idea or option 1.

@evan-bradley
Copy link
Contributor

I'm split with options 1 and 2. If we add an extra parameter, one will always be unused, and to me that's a little odd. On the other hand, overloading it with either cases or character delimiters feels like we're mixing up two concepts (even if they're fairly closely related). I think one thing that would help me feel better about option 2 is if we added a few more common separators (- and | come to mind) as named cases. This would make it so that the fallback of using a character hopefully becomes a rare exception.

One thing I like about option 3 is that it is explicit. It makes the difference between the two ideas (naming case vs. delimiter) very clear, even if there is some overlap in functionality.

@github-actions
Copy link
Contributor

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.

@TylerHelmuth
Copy link
Member

With #20879 I think optional parameters will be the solution to this issue.

@github-actions
Copy link
Contributor

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.

@github-actions
Copy link
Contributor

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.

@TylerHelmuth
Copy link
Member

Optional Parameter support is released which means we can come back to this issue. I feel the solution is to add a new optional parameter

@TylerHelmuth TylerHelmuth added help wanted Extra attention is needed good first issue Good for newcomers Contribfest labels Oct 11, 2023
@TylerHelmuth TylerHelmuth removed help wanted Extra attention is needed good first issue Good for newcomers labels Oct 21, 2023
@TylerHelmuth TylerHelmuth added the help wanted Extra attention is needed label Dec 13, 2023
@TylerHelmuth TylerHelmuth added the good first issue Good for newcomers label Dec 13, 2023
Copy link
Contributor

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.

Copy link
Contributor

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.

@evan-bradley
Copy link
Contributor

It would be nice to find a common term between "delimiter" and "case" and have a function that has case and delimiter optional parameters the user can pass to specify how to format the output string. Barring that, making the case in ConvertCase optional and adding a delimiter optional parameter should suffice.

Copy link
Contributor

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.

Copy link
Contributor

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.

@github-actions github-actions bot added the Stale label Aug 19, 2024
Copy link
Contributor

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed as inactive enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed pkg/ottl Stale
Projects
None yet
Development

No branches or pull requests

3 participants