-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[pkg/ottl] Fix OTTL functions by using setters #39416
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
Merged
Merged
Changes from 2 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
c68cc6a
[pkg/ottl] Fix OTTL functions by using setters
rockdaboot 6b38c4c
Merge branch 'main' into fix-39100
rockdaboot 903a86d
Remove superfluous MoveTo() from flatten function
rockdaboot 2ffa616
Rename targetGetter to target in merge_maps test
rockdaboot 2a50ad1
Use CopyTo in test setters
rockdaboot b508ca4
Remove the 'updated' intermediate map in replace_all_matches
rockdaboot dabd3bb
Merge branch 'main' into fix-39100
rockdaboot 1c315d5
Merge remote-tracking branch 'upstream/main' into fix-39100
rockdaboot 8ac77ad
Tests: check that setter has been called
rockdaboot 5437b1b
Merge remote-tracking branch 'upstream/main' into fix-39100
rockdaboot 402aeed
Fix profiles accessAttributesKey() for e2e tests
rockdaboot c9e5756
Add OTTL e2e tests based on profiles
rockdaboot 15921d0
Appease linter
rockdaboot 30358f0
Revert last three commits in favor of #40931
rockdaboot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Use this changelog template to create an entry for release notes. | ||
|
|
||
| # One of 'breaking', 'deprecation', 'new_component', 'enhancement', 'bug_fix' | ||
| change_type: bug_fix | ||
|
|
||
| # The name of the component, or a single word describing the area of concern, (e.g. filelogreceiver) | ||
| component: pkg/ottl | ||
|
|
||
| # A brief description of the change. Surround your text with quotes ("") if it needs to start with a backtick (`). | ||
| note: Fix OTTL functions by using setters. | ||
|
|
||
| # Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists. | ||
| issues: [39100] | ||
|
|
||
| # (Optional) One or more lines of additional information to render under the primary note. | ||
| # These lines will be padded with 2 spaces and then inserted directly into the document. | ||
| # Use pipe (|) for multiline entries. | ||
| subtext: | ||
|
|
||
| # If your change doesn't affect end users or the exported elements of any package, | ||
| # you should instead start your pull request title with [chore] or use the "Skip Changelog" label. | ||
| # Optional: The change log or logs in which this entry should be included. | ||
| # e.g. '[user]' or '[user, api]' | ||
| # Include 'user' if the change is relevant to end users. | ||
| # Include 'api' if there is a change to a library API. | ||
| # Default: '[user]' | ||
| change_logs: [user] |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
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.
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.
The call to
MoveToabove is already updating the map behind the scenes without needing to calltarget.set. Those calls, as well as any.CopyTocalls against the target map will need to be removed.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.
@TylerHelmuth Calling
target.Setis mandatory here, since the attributes in the profiles signal can not be rendered aspcommon.Map. The setter has to take the values from the map and update two arrays, the lookup table and the array of indices into the lookup table. So for profiles,CopyToorMoveTowithouttarget.Setare essential no-ops and those should be removed. That's possibly what you meant, but you wrote it differently. Can you clarify, please?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.
Anyway, addressed this in func_flatten as it makes sense to me.
Uh oh!
There was an error while loading. Please reload this page.
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.
I'm wondering if we could extend the
pcommon.Mapto support creating read-only shallow copies of the original Map, setting the internal state toStateReadOnly. When this Map's state is set, it ensures that no data modification is performed and panics if that happen, which IMO would be fine, considering trying to modify read-only data should be considered a programming error.Example:
With that functionality, we could either make the
PMapGetSetterGet (and probably other map getters) return read-only values, or change it on the OTTL context path getters.Thoughts?
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.
@edmocosta thats a good idea to enforce what we want.
@rockdaboot what I meant is that if we're trying to enforce that maps be set via the context's setter instead of via pdata functions, we should be consistent. In the case of flatten (and I think a majority of our editors that work on maps) we are calling ether
CopyToorMoveToon the target instead of calling a setter. If a function does that and then also calls the.Setfunction, for most contexts it'll end up callingCopyToorMoveTotwice.Since we're being consistent calling the context's setter, we need to remove the additional
CopyToorMoveToin the function.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.
@edmocosta Good idea. Are you going to create an issue/PR? Does this PR has to wait for the new functionality or can we add read-only maps later? Just looking for clarity here.
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.
Maybe check merge_maps and the replace_all_patterns key scenario.
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.
I don't think we need to block this PR because of that, those changes might take some time to get through, so I'd do it later. I'll be opening the issues for implementing that soon.
The only thing I'd do in this PR is what Tyler mentioned at #39416 (comment), so when we introduce the read-only stuff it wouldn't break.
Uh oh!
There was an error while loading. Please reload this page.
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.
@TylerHelmuth In both functions, the
CopyTohas notpcommon.Mapas source/target, instead that is onpcommon.Value. Can you give a concrete example of your idea for improvement? Inctxutil.SetMap()we could test the destination ans source map for equality and if true, skip theCopyTo()or do this check/skip insideMap.CopyTo(). But it feels out-of-scope for this PR.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.
FYI, I've opened a PR adding the read-only functions: open-telemetry/opentelemetry-collector#12995