-
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 flatten function #30455
Merged
TylerHelmuth
merged 8 commits into
open-telemetry:main
from
TylerHelmuth:ottl-flatten-function
Jan 17, 2024
Merged
[pkg/ottl] Add flatten function #30455
TylerHelmuth
merged 8 commits into
open-telemetry:main
from
TylerHelmuth:ottl-flatten-function
Jan 17, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TylerHelmuth
requested review from
bogdandrutu and
evan-bradley
as code owners
January 11, 2024 22:00
danelson
reviewed
Jan 11, 2024
TylerHelmuth
force-pushed
the
ottl-flatten-function
branch
from
January 11, 2024 22:18
78627a3
to
96728b9
Compare
TylerHelmuth
force-pushed
the
ottl-flatten-function
branch
from
January 11, 2024 22:58
7da070b
to
d9fab7d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me overall. I'm good with this being an Editor for the same reasons you called out.
evan-bradley
approved these changes
Jan 16, 2024
Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
mfyuce
pushed a commit
to mfyuce/opentelemetry-collector-contrib
that referenced
this pull request
Jan 18, 2024
**Description:** Adds a `flatten` function that allows flattening maps. I went with an editor instead of a converter, but I'm open to debate. Using an editor means that a user can do `flatten(body) where IsMap(body)` instead of `set(body, Flatten(body)) where IsMap(body). When using ParseJson you have to do: ``` - merge_maps(cache, ParseJSON(body), "upsert") - flatten(cache) ``` instead of `merge_maps(cache, Flatten(ParseJSON(body)), "upsert")`. Ultimately I went with an editor for similar reasons that `merge_maps` is an editor: chaining too many functions together is messy and updating maps is very fast with pdata. The function supports 2 optional parameters, `prefix` and `depth`. Use `prefix` to add a "namespace" to the values that are being flattened. Use `depth` to prevent trying to flatten maps that are too deep. See the function doc for examples. **Link to tracking Issue:** <Issue number if applicable> Closes open-telemetry#29283 **Testing:** <Describe what testing was performed and which tests were added.> Added new unit and e2e tests. Please scrutinize. **Documentation:** <Describe the documentation added.> Added function doc. --------- Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
cparkins
pushed a commit
to AmadeusITGroup/opentelemetry-collector-contrib
that referenced
this pull request
Feb 1, 2024
**Description:** Adds a `flatten` function that allows flattening maps. I went with an editor instead of a converter, but I'm open to debate. Using an editor means that a user can do `flatten(body) where IsMap(body)` instead of `set(body, Flatten(body)) where IsMap(body). When using ParseJson you have to do: ``` - merge_maps(cache, ParseJSON(body), "upsert") - flatten(cache) ``` instead of `merge_maps(cache, Flatten(ParseJSON(body)), "upsert")`. Ultimately I went with an editor for similar reasons that `merge_maps` is an editor: chaining too many functions together is messy and updating maps is very fast with pdata. The function supports 2 optional parameters, `prefix` and `depth`. Use `prefix` to add a "namespace" to the values that are being flattened. Use `depth` to prevent trying to flatten maps that are too deep. See the function doc for examples. **Link to tracking Issue:** <Issue number if applicable> Closes open-telemetry#29283 **Testing:** <Describe what testing was performed and which tests were added.> Added new unit and e2e tests. Please scrutinize. **Documentation:** <Describe the documentation added.> Added function doc. --------- Co-authored-by: Evan Bradley <11745660+evan-bradley@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description:
Adds a
flatten
function that allows flattening maps.I went with an editor instead of a converter, but I'm open to debate. Using an editor means that a user can do
flatten(body) where IsMap(body)
instead of `set(body, Flatten(body)) where IsMap(body). When using ParseJson you have to do:instead of
merge_maps(cache, Flatten(ParseJSON(body)), "upsert")
. Ultimately I went with an editor for similar reasons thatmerge_maps
is an editor: chaining too many functions together is messy and updating maps is very fast with pdata.The function supports 2 optional parameters,
prefix
anddepth
. Useprefix
to add a "namespace" to the values that are being flattened. Usedepth
to prevent trying to flatten maps that are too deep. See the function doc for examples.Link to tracking Issue:
Closes #29283
Testing:
Added new unit and e2e tests. Please scrutinize.
Documentation:
Added function doc.