-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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] Add string convert case function (lower, upper, snake) #16083
[pkg/ottl] Add string convert case function (lower, upper, snake) #16083
Conversation
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clarkjohnd thanks for doing this so quickly.
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
Signed-off-by: John Clark <[email protected]>
@TylerHelmuth cheers for the feedback, updated with using that library and for the sake of it while doing the work have added camel case conversion using that library too, probably not useful for metric names but some might find it useful for attribute names or values etc. at some point. Existing tests pass using that library with snake case function. |
Signed-off-by: John Clark <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clarkjohnd couple more nits then we'll be good to go. Thanks!
Signed-off-by: John Clark <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@clarkjohnd thanks for your first contribution!
I'll follow up with a PR to get the function working in transform processor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me. Thanks for taking this one.
@clarkjohnd please run |
Signed-off-by: John Clark <[email protected]>
…en-telemetry#16083) * Add snake case func Signed-off-by: John Clark <[email protected]> * Add upper and lower case convert Signed-off-by: John Clark <[email protected]> * Add snake case test cases Signed-off-by: John Clark <[email protected]> * Add lower and upper test cases Signed-off-by: John Clark <[email protected]> * Add default case op Signed-off-by: John Clark <[email protected]> * Add no op test cases Signed-off-by: John Clark <[email protected]> * Add nil target test Signed-off-by: John Clark <[email protected]> * Add non-string test case Signed-off-by: John Clark <[email protected]> * Update README Signed-off-by: John Clark <[email protected]> * Add example Signed-off-by: John Clark <[email protected]> * Add changelog Signed-off-by: John Clark <[email protected]> * Update changelog issue Signed-off-by: John Clark <[email protected]> * Fixes in line with PR 15709 Signed-off-by: John Clark <[email protected]> * Add error handling for unset case types Signed-off-by: John Clark <[email protected]> * Split case functions and refactor Signed-off-by: John Clark <[email protected]> * Refactor tests and add error test for case Signed-off-by: John Clark <[email protected]> * Update readme and change error messages Signed-off-by: John Clark <[email protected]> * Switch to snake case library Signed-off-by: John Clark <[email protected]> * Add camel case Signed-off-by: John Clark <[email protected]> * Change validation Signed-off-by: John Clark <[email protected]> * Fix import Signed-off-by: John Clark <[email protected]> * Add camel case comment Signed-off-by: John Clark <[email protected]> * Remove dedicated functions Signed-off-by: John Clark <[email protected]> * Final fixes and tidy up Signed-off-by: John Clark <[email protected]> * make gotidy output Signed-off-by: John Clark <[email protected]> Signed-off-by: John Clark <[email protected]>
Description:
Adds a function (
ConvertCase(target, toCase)
) to OTTL that converts strings (target
) to the following options (toCase
):lower
upper
snake
Originally part of #15379, migrated from
metrictransformprocessor
to OTTL functions to be able to be used inset
operations withintransformprocessor
instead in separate pull request.Existing linked PRs will be closed after this one.
@TylerHelmuth @dmitryax
Link to tracking Issue: #15379, #16070
Testing:
Plenty of test cases for each type of case as well as handling
nil
and empty inputs to the target string and case type. Function tested in dev build with dev branch of transform processor.Documentation:
READMEs updated with documented function as well as example use case in transform processor as per other functions.