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
4 changes: 2 additions & 2 deletions pkg/ottl/contexts/internal/ctxprofile/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,11 @@ func getAttributeValue[K Context](tCtx K, key string) pcommon.Value {
// 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 {
for _, tableIndex := range tCtx.GetProfile().AttributeIndices().All() {
attr := table.At(int(tableIndex))
if attr.Key() == key {
// Copy the value because OTTL expects to do inplace updates for the values.
v := pcommon.NewValueEmpty()
attr.Value().CopyTo(v)
return v
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,11 +203,11 @@ func getAttributeValue[K Context](tCtx K, key string) pcommon.Value {
// 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.GetProfileSample().AttributeIndices().AsRaw()

for _, tableIndex := range indices {
for _, tableIndex := range tCtx.GetProfileSample().AttributeIndices().All() {
attr := table.At(int(tableIndex))
if attr.Key() == key {
// Copy the value because OTTL expects to do inplace updates for the values.
v := pcommon.NewValueEmpty()
attr.Value().CopyTo(v)
return v
Expand Down
12 changes: 5 additions & 7 deletions pkg/ottl/contexts/internal/logprofile/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,19 @@ func getMapping(dict pprofile.ProfilesDictionary, idx int32) (mapping, error) {
return newMapping(dict, mTable.At(int(idx)))
}

func getLocations(dict pprofile.ProfilesDictionary, locIdxs []int32,
start, length int32,
) (locations, error) {
if start >= int32(len(locIdxs)) {
func getLocations(dict pprofile.ProfilesDictionary, locIdxs pcommon.Int32Slice, start, length int32) (locations, error) {
if start >= int32(locIdxs.Len()) {
return locations{}, fmt.Errorf("location start index out of bounds: %d", start)
}
if start+length > int32(len(locIdxs)) {
if start+length > int32(locIdxs.Len()) {
return locations{}, fmt.Errorf("location end index out of bounds: %d", start+length)
}

locTable := dict.LocationTable()
var joinedErr error
ls := make(locations, 0, length)
for i := range length {
locIdx := locIdxs[start+i]
locIdx := locIdxs.At(int(start + i))
l, err := newLocation(dict, locTable.At(int(locIdx)))
joinedErr = errors.Join(joinedErr, err)
ls = append(ls, l)
Expand Down Expand Up @@ -138,7 +136,7 @@ type ProfileSample struct {
func (s ProfileSample) MarshalLogObject(encoder zapcore.ObjectEncoder) error {
var joinedErr error

locs, err := getLocations(s.Dictionary, s.Profile.LocationIndices().AsRaw(), s.LocationsStartIndex(), s.LocationsLength())
locs, err := getLocations(s.Dictionary, s.Profile.LocationIndices(), s.LocationsStartIndex(), s.LocationsLength())
joinedErr = errors.Join(joinedErr, err)
joinedErr = errors.Join(joinedErr, encoder.AddArray("locations", locs))

Expand Down
Loading