Skip to content

Commit 402aeed

Browse files
committed
Fix profiles accessAttributesKey() for e2e tests
1 parent 5437b1b commit 402aeed

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

pkg/ottl/contexts/internal/ctxprofile/profile.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,11 +348,27 @@ func accessAttributesKey[K Context](key []ottl.Key[K]) ottl.StandardGetSetter[K]
348348
if err != nil {
349349
return err
350350
}
351-
v := pcommon.NewValueEmpty()
351+
v := getAttributeValue(tCtx, *newKey)
352352
if err = ctxutil.SetIndexableValue[K](ctx, tCtx, v, val, key[1:]); err != nil {
353353
return err
354354
}
355355
return pprofile.PutAttribute(tCtx.GetProfilesDictionary().AttributeTable(), tCtx.GetProfile(), *newKey, v)
356356
},
357357
}
358358
}
359+
360+
func getAttributeValue[K ProfileContext](tCtx K, key string) pcommon.Value {
361+
// Find the index of the attribute in the profile's attribute indices
362+
// and return the corresponding value from the attribute table.
363+
table := tCtx.GetProfilesDictionary().AttributeTable()
364+
indices := tCtx.GetProfile().AttributeIndices().AsRaw()
365+
366+
for _, tableIndex := range indices {
367+
attr := table.At(int(tableIndex))
368+
if attr.Key() == key {
369+
return attr.Value()
370+
}
371+
}
372+
373+
return pcommon.NewValueEmpty()
374+
}

0 commit comments

Comments
 (0)