Skip to content

profcheck: use dedicated check for AttributeTable#109

Open
florianl wants to merge 1 commit intomainfrom
profcheck-attrTable
Open

profcheck: use dedicated check for AttributeTable#109
florianl wants to merge 1 commit intomainfrom
profcheck-attrTable

Conversation

@florianl
Copy link
Copy Markdown
Member

As KeyValueAndUnit uses pcommon.AnyValue as type for field Value we need to explicitly check the value of pcommon.AnyValue if it is nil rather than check if Value of KeyValueAndUnit is nil.

Fixes open-telemetry/opentelemetry-ebpf-profiler#1360 and avoid the need for work arounds in various places.

As KeyValueAndUnit uses pcommon.AnyValue as type for field Value we need to
explicitly check the value of pcommon.AnyValue if it is nil rather than check if
Value of KeyValueAndUnit is nil.

Fixes open-telemetry/opentelemetry-ebpf-profiler#1360
and avoid the need for work arounds in various places.

Signed-off-by: Florian Lehner <florian.lehner@elastic.co>
@florianl florianl requested a review from a team as a code owner April 20, 2026 07:39
Comment thread profcheck/check.go
// key and unit indices and the value field holds nil as value.
func checkAttributeTableZeroVal(attrTable []*profiles.KeyValueAndUnit) error {
if len(attrTable) == 0 {
return errors.New("empty table, must have at least zero value entry")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
return errors.New("empty table, must have at least zero value entry")
return errors.New("empty attribute table, must have at least zero value entry")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

For consistency with checkZeroVal() I'm keeping the error message.

Copy link
Copy Markdown
Member

@christos68k christos68k Apr 21, 2026

Choose a reason for hiding this comment

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

I think in this case, we can do better as the primary utility of this logic is to point out violations. So all these empty table errors (not just attribute table) can be a lot better in mentioning the actual table that violates the spec (rather than "empty table" which leaves the user manually having to inspect data to figure out the source of the violation).

We don't have to do that in this PR, LMK what you think.

@aalexand
Copy link
Copy Markdown
Member

@florianl Curious - why is it not "pure" zero value with all fields unset? Why is the value field set?

@florianl
Copy link
Copy Markdown
Member Author

why is it not "pure" zero value with all fields unset? Why is the value field set?

The core issue is an encoding problem. Since the Value field within KeyValueAndUnit is not a pointer receiver, it is always initialized. Therefore, to check if the value is meaningfully absent, we must inspect the inner Value.value field of KeyValueAndUnit.Value for nil.
Since the OTel ecosystem relies on a custom implementation for marshaling and unmarshaling protobufs, we must address this case, even though other Go protobuf implementations might handle it differently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: profiles from ebpf-profiler:0.150.1 are failing the dict check for attribute_table

3 participants