Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions .chloggen/ottl-e2e-profiles.yaml
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 an issue where the attribute values were amended in the profiles dictionary.

# Mandatory: One or more tracking issues related to the change. You can use the PR number here if no issue exists.
issues: [40738]

# (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]
20 changes: 19 additions & 1 deletion pkg/ottl/contexts/internal/ctxprofile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,29 @@ func accessAttributesKey[K Context](key []ottl.Key[K]) ottl.StandardGetSetter[K]
if err != nil {
return err
}
v := pcommon.NewValueEmpty()
v := getAttributeValue(tCtx, *newKey)
if err = ctxutil.SetIndexableValue[K](ctx, tCtx, v, val, key[1:]); err != nil {
return err
}
return pprofile.PutAttribute(tCtx.GetProfilesDictionary().AttributeTable(), tCtx.GetProfile(), *newKey, v)
},
}
}

func getAttributeValue[K ProfileContext](tCtx K, key string) pcommon.Value {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit confused with this fix, is overriding the existing keys at the profile dictionary expected here? considering it would indirectly change the value for all other references? Last time we discussed it duplicating keys was expected (#39681 (comment)), have it changed? If I'm not mistaken, that described scenario won't happen anymore with this fix, and the dictionary table item will be updated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good spot!
We definitely must not change any existing value in the dictionary attribute table here. Just pushed a fix for it and will later add tests that ensure that the dictionary attribute table isn't changed when adding or changing attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will also change the changelog to bug_fix and amend the description.

Copy link
Contributor Author

@rockdaboot rockdaboot Jul 9, 2025

Choose a reason for hiding this comment

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

  1. amended the changelog
  2. added a validation of dictionary tables to ensure that existing entries are not changed by operations. Does it make sense to do the validation in other test functions as well?

The validator could possibly be moved into pprofiletest, maybe in a follow-up PR.

Copy link
Contributor

@edmocosta edmocosta Jul 10, 2025

Choose a reason for hiding this comment

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

Does it make sense to do the validation in other test functions as well?

Converters should not change telemetry data, so it should be fine as it's (although we know they can sneakily do it by leveraging references).

// Find the index of the attribute in the profile's attribute indices
// and return the corresponding value from the attribute table.
table := tCtx.GetProfilesDictionary().AttributeTable()
indices := tCtx.GetProfile().AttributeIndices().AsRaw()

for _, tableIndex := range indices {
attr := table.At(int(tableIndex))
if attr.Key() == key {
v := pcommon.NewValueEmpty()
attr.Value().CopyTo(v)
return v
}
}

return pcommon.NewValueEmpty()
}
Loading