-
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
[processor/transform] Unable to get item from slice resource attributes value #16811
Comments
Pinging code owners:
See Adding Labels via Comments if you do not have permissions to add labels yourself. |
Thanks for reporting this. You're right that the OTTL currently doesn't support indexing slices. I think the solution that would be most obvious to most users would be the first statement you suggested that uses array indexing notation. Calling a method on a slice is an interesting concept, but I'm not sure whether we'd want to introduce OOP concepts to the OTTL. I see two potential solutions to offer slice indexing:
I think the first option is likely the best path forward, but would be interested in others' opinions. |
index operator fits in with the language since we already use it with map access. Will need to determine how to make sure the grammar can differentiate between |
Thanks for providing the potential solutions. I prefer the first option too. Are there any suggestions to differentiate the slice from the map in OTTL index operator grammar? |
It shouldn't be difficult since the invocation struct is already separate from the path struct that uses indexing. I was more talking about reading the language and comprehending that we're accessing a slice instead of a map. We need to make sure statements are easy to understand. |
Great! |
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. |
@evan-bradley I've started working on this and need some opinions. When talking about indexing with OTTL I think their are 2 categories: map indexing and slice indexing. I think OTTL should make these assumptions:
Allowing any number of "keys" after any Handling indexing and
|
Reflecting on this a little more, I think disallowing
If we do choose to continue disallowing "downward" access it would mean that |
@TylerHelmuth Thanks for the detailed writeup. I agree with the indexing assumptions you outlined, I think those are all reasonable. Based on what you've written and the decision to remove the support for sub-pathing on slice/map values in paths, I think moving path indexing into the parser is also a good call. |
@TylerHelmuth I worked on this some more and have more realizations to discuss:
Here is a link to the setting in PoC branch.. I tested it briefly via the transformprocessor's "e2e" tests and it works, but I don't like this. There is a lot of "leaking" happening right now with this feature that I'm beginning to feel uncomfortable with. More and more logic that I feel has to do with the underlying telemetry is seeping into the parser and I don't think it will scale well. Before we move forward with this approach I want to try another. Instead of moving indexing into the parser for paths, we could leave the contexts as the source of truth. At the moment we only pass in string literals, but in the future if we choose to allow paths to be used as keys, we could pass in Getters which could be executed during hot path execution. Leaving the indexing of paths to the contexts is pretty straight forward, but we'd have to decide how to handle Converters. Options I'm pondering
|
Here is a very quick example of letting the context handle the indexing: 5e77d32#diff-b6a04373af227be3fc277b1626e64736223ed0f678265774a18be3cf6c6c6dbb. In the future dynamic keys could be supported by making the |
I've just spoken with Tyler about this at length, and our takeaways are:
|
I think we're in agreement to keep Path indexing a responsibility of the Contexts. I will work on getting that implemented and then see what is shareable between Path indexing and Converter indexing. On the topic of Our contexts are actually bad at doing this today. For example, you can do @evan-bradley what do you think? |
I think that makes sense given the decision to keep path parsing in the contexts. I'm not sure there will be a need for it anytime soon given the value types supported in pdata Maps, but it's good to provide more flexibility for the contexts where we can. If we can have the contexts validate on startup that no sub-pathing or indexing happens where it doesn't make sense based on the types, then there's really no motivation to do it in the parser. |
Component(s)
processor/transform
Is your feature request related to a problem? Please describe.
Hi, I'm trying to use the generated
slice
result by theSplit
function in transform processor statements. But I didn't find any working solution to access the item inslice
result.Describe the solution you'd like
Expected statements:
or
Describe alternatives you've considered
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: