-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 rename
function
#31901
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
On one hand we have an existing solution for renaming an attribute and it is the same solution that If we were to introduce a If only changing the key name, I think the function would look like |
Thank you for the prompt reply! @AlexanderWert @michalpristas if you have any more thoughts on this let me know. |
@TylerHelmuth Thanks for the clarification!
@TylerHelmuth What is the default behavior with
IMHO it would be beneficial for the usability to have a more intuitive name for renaming an attribute. As you wrote |
Good question. I believe it will cause |
The initial PR had exactly the simplified version of
The |
Reverted the latest changes back to to the initial rename
The
This combines what previously required two calls of How the
|
@aleksmaus do you have availability to bring this topic to the Collector SIG meeting? I think this function has enough edge cases to warrant a discussion there. |
I have one meeting overlapping today at work, will see what I can do. If not this week then the next one. |
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 Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
After few discussions with the team, we are not going to pursue this change any further, closing this issue.
|
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
It might be useful to be able to
rename
the field with one call which currently requires two calls:set
anddelete_key
.This follows the initial proposal for strategy resolution for the
set
function by @michalpristas here #31808Related to the initial implementation here: #31769
Describe the solution you'd like
For example
Instead of these two of calls
Use
Documentation
rename
rename(target, source_map, source_key, [Optional] ignore_missing = true, [Optional] conflict_strategy = upsert)
The
rename
function combinesset
anddelete_key
calls in one function. It creates thetarget
field with thesource_key
value fromsource_map
and it deletes thesource_key
fromsource_map
.target
is a path expression to a telemetry field.source_map
is a path expression to apcommon.Map
type field.source_key
is a string key forsource_map
.How the
rename
function behaves is controlled by the optionalignore_missing
andconflict_strategy
arguments.ignore_missing
is optional boolean argument that specifies what happens when thesource_key
is missing from thesource_map
. It is set totrue
by default.true
value results in no changes if thesource_key
key doesn't exists in thesource_map
false
value results in error if thesource_key
key doesn't exists in thesource_map
conflict_strategy
is an optional string parameter that specifies the conflict resolution strategy for thetarget
.Valid values are
upsert
,fail
, andinsert
. By default, it is set toupsert
.upsert
overwrites thetarget
value if it is already present.fail
returns an error iftarget
is already present.insert
results in no changes iftarget
is already present.Examples:
rename(attributes["destination"], body, "source")
rename(attributes["destination"], attributes, "source", false)
rename(attributes["destination"], attributes, "source", true, "insert")
Describe alternatives you've considered
No response
Additional context
The function signature could have been better if we could do something like this
rename(attributes["destination"], body["source"])
Still leaning this product, didn't find a way to figure out the source key from expression like this.
The text was updated successfully, but these errors were encountered: