-
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] Set method should allow dynamically setting map values to attributes #14946
Comments
I can think of two ways to handle this situation:
I would opt for the second because I like the flexibility that Factory Functions provide. I prefer putting business logic in the function vs the contexts. @bogdandrutu @kentquirk @evan-bradley what do you think? |
I agree, I think a function would be better for this sort of operation. In addition to keeping business logic out of the contexts I think it also provides a good pattern for doing other types of matching (regex, filtering, etc.), and makes it more explicit what is going on. |
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. |
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. |
Is this functionality still required? If yes, I would like to have a look |
@odubajDT some solution to make dynamic interactions in OTTL is still desired. I havent spent much time on this problem so I'm open to suggestions. I do know I don't want to change how set works, so the solution should be something else. |
One of the solutions that comes into my mind is creating a separate
where
And the resulting
WDYT @evan-bradley @TylerHelmuth ? Thanks for the opinions! Just and additional though here, when implementing this function, would it makes sense to actually also implement a |
Created a draft implementation of the potential solution, will appreciate your opinions! |
Sorry for the delay in taking a look at this. We have keep_matching_keys now, would it be possible to do something like the following to solve this case?
I think it should be functionally equivalent to having a single Converter for both copying and modifying the map, and shouldn't be much less performant.
I think we should have this with the flatten Editor. Does that match what you have in mind? |
That's probably true, do you think we should close the issue and the PR? |
@evan-bradley's solution is acceptable for now. Let's not close this issue tho until that example solution for this scenario is documented in the transformprocessor's readme. This is a common scenario but that solution isn't easy to think up unless you know OTTL well. |
Opened an issue to document the example configuration #35893 |
Is your feature request related to a problem? Please describe.
While using transform processor, we tried setting set kubernetes labels to a single attribute 'labels' in a body as below.
But Set method doesn't iterate through the map of values & instead needs all keys in array to be explicitly mentioned like below-
set(attributes["kubernetes.labels"], resource.attributes["pod_labels_app"])
Kubernetes labels is something dynamic things & we can't explicitly mention label name in OTEL processor rules.
Describe the solution you'd like
Set method in here should allow iterate through the map & fetch all values so that we can perform something like this-
set(attributes["kubernetes.labels"], resource.attributes["pod_labels_*"])
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: