Skip to content
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] Fix handling of slice values in flatten function by considering depth option #36198

Merged
merged 6 commits into from
Nov 15, 2024

Conversation

bacherfl
Copy link
Contributor

@bacherfl bacherfl commented Nov 5, 2024

Description

This PR adapts the flatten function to also consider the depth option when handling slice values. Before this change, the function flattened slice values beyond the given depth.

Link to tracking issue

Fixes #36161

Testing

Added unit and e2e tests

Documentation

No changes here, as the docs already mention the expected behavior of the function when the depth option is set

Signed-off-by: Florian Bacher <[email protected]>
Signed-off-by: Florian Bacher <[email protected]>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a new test for the new error condition of depth=0

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add an e2e test for flattening a slice and a map with a set depth

Copy link
Contributor Author

@bacherfl bacherfl Nov 13, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should already be covered by https://github.com/open-telemetry/opentelemetry-collector-contrib/pull/36198/files#diff-90b6e27c60a80c3c831576a03b3bd0a47839bfb606a9d2876d8ccf6bf1370c92R109 - this test contains both a slice and a map and has been adjusted since the flattening previously did not stop at level 1 for the slice.

Signed-off-by: Florian Bacher <[email protected]>
@evan-bradley evan-bradley merged commit f6cebd2 into open-telemetry:main Nov 15, 2024
158 checks passed
@github-actions github-actions bot added this to the next release milestone Nov 15, 2024
RutvikS-crest pushed a commit to RutvikS-crest/opentelemetry-collector-contrib that referenced this pull request Dec 9, 2024
…idering `depth` option (open-telemetry#36198)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This PR adapts the `flatten` function to also consider the `depth`
option when handling slice values. Before this change, the function
flattened slice values beyond the given depth.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#36161 

<!--Describe what testing was performed and which tests were added.-->
#### Testing

Added unit and e2e tests

<!--Describe the documentation added.-->
#### Documentation

No changes here, as the docs already mention the expected behavior of
the function when the `depth` option is set
<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Florian Bacher <[email protected]>
Co-authored-by: Evan Bradley <[email protected]>
sbylica-splunk pushed a commit to sbylica-splunk/opentelemetry-collector-contrib that referenced this pull request Dec 17, 2024
…idering `depth` option (open-telemetry#36198)

<!--Ex. Fixing a bug - Describe the bug and how this fixes the issue.
Ex. Adding a feature - Explain what this achieves.-->
#### Description

This PR adapts the `flatten` function to also consider the `depth`
option when handling slice values. Before this change, the function
flattened slice values beyond the given depth.

<!-- Issue number (e.g. open-telemetry#1234) or full URL to issue, if applicable. -->
#### Link to tracking issue
Fixes open-telemetry#36161 

<!--Describe what testing was performed and which tests were added.-->
#### Testing

Added unit and e2e tests

<!--Describe the documentation added.-->
#### Documentation

No changes here, as the docs already mention the expected behavior of
the function when the `depth` option is set
<!--Please delete paragraphs that you did not use before submitting.-->

---------

Signed-off-by: Florian Bacher <[email protected]>
Co-authored-by: Evan Bradley <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pkg/ottl] unexpected behavior of flatten function when handling slice attributes at top level
4 participants