Closed
Description
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
OTTL supports indexing maps and slices with dynamic values (#36644), allowing statements to access elements using any ottl.mathExprLiteral
literal (Int
, String
, Converter
, Path
), which is great.
Maybe, It would be useful to extend the slice indexing support with math expressions, so we would be able to also access elements that needs some kind of computation. For example, to get the last slice's element, we can currently use:
log_statements:
- context: log
statements:
- set(cache["last"], Len(attributes["array.attribute"]) - 1)
- set(attributes["new"], attributes["array.attribute"][cache["last"]])
With math expression support, we could avoid using the cache and express the above statements as:
log_statements:
- context: log
statements:
- set(attributes["new"], attributes["array.attribute"][Len(attributes["array.attribute"]) - 1)])
Describe the solution you'd like
--
Describe alternatives you've considered
Using cache
, which also seems reasonable.
Additional context
No response