-
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 map literals #32388
Comments
Pinging code owners for pkg/ottl: @TylerHelmuth @kentquirk @bogdandrutu @evan-bradley. 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. |
@evan-bradley if this issue is still available, I would like to work on this |
That would be great @bacherfl, thank you. |
A few thoughts in response to #34168 (review):
|
How will non-static values be handled? |
Do list literals allow Enums Converters Editors, and MathExpressions? |
They'll be evaluated as part of the statement. I think that's the most intuitive way to handle it.
They do. It's worth noting that editors are explicitly disallowed; the parser will catch them and return an error if it sees one. |
Ok, we should match the same types as list. |
**Description:** This PR extends the OTTL grammar to support map literals **Link to tracking Issue:** #32388 **Testing:** Unit tests; E2E Tests **Documentation:** Extended the docs with a section about the added data type --------- Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
**Description:** This PR extends the OTTL grammar to support map literals **Link to tracking Issue:** open-telemetry#32388 **Testing:** Unit tests; E2E Tests **Documentation:** Extended the docs with a section about the added data type --------- Signed-off-by: Florian Bacher <florian.bacher@dynatrace.com>
Component(s)
pkg/ottl
Is your feature request related to a problem? Please describe.
Currently there is no way in OTTL to create a new map. This makes certain use cases difficult and limits the language's expressiveness.
Describe the solution you'd like
Use
{"key": value, [...]}
as a map literal syntax, similar to how it looks in JavaScript, JSON, or Go structs. In particular, I would like the following to be possible when retaining the original log body while parsing a log:Describe alternatives you've considered
Instead of map literals, we could add a
Map
function with optional parameters to create keys in the initial map. However, I think maps are important enough in OTLP to justify adding map literals to the language.Additional context
Implementation will broadly look something like the following:
buildLexer
ingrammar.go
to understand map literals.grammar.go
to capture keys and values in the map.The text was updated successfully, but these errors were encountered: