Skip to content
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

Make pprofile attribute table a real slice #11706

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

dmathieu
Copy link
Member

@dmathieu dmathieu commented Nov 19, 2024

Description

AttributeTable was setup as a map of attributes, same as they are used in traces.
However, for profiles, they have a different meaning. They store a slice of attributes, and samples will point to the index of each attribute rather than duplicate the value.

So this can't be a map, it must be a slice of key/values, which can be duplicated and need a reliable index.

See https://github.com/open-telemetry/opentelemetry-proto/blob/793e43e25f2eb8063c2693bc2e66e16672cf7ed8/opentelemetry/proto/profiles/v1development/profiles.proto#L204-L205

cc @mx-psi

Copy link

codecov bot commented Nov 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.57%. Comparing base (c42139c) to head (f8fe840).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #11706      +/-   ##
==========================================
+ Coverage   91.54%   91.57%   +0.02%     
==========================================
  Files         442      444       +2     
  Lines       23792    23873      +81     
==========================================
+ Hits        21780    21861      +81     
  Misses       1641     1641              
  Partials      371      371              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

if lai := sample.Attributes().Len(); lai > 0 {
b.logEntry(" Attributes:")
for j := 0; j < lai; j++ {
if sample.Attributes().At(j) <= math.MaxInt32 {
Copy link
Member Author

Choose a reason for hiding this comment

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

The next version of the proto uses an int32 rather than an uint64 here. So after the next proto release/upgrade, we won't need this check anymore.

@dmathieu dmathieu marked this pull request as ready for review November 19, 2024 13:43
@dmathieu dmathieu requested a review from a team as a code owner November 19, 2024 13:43
@dmathieu dmathieu added this to the Profiling support milestone Nov 19, 2024
//
// Must use NewAttributeTableSlice function to create new instances.
// Important: zero-initialized instance is not valid for use.
type AttributeTableSlice struct {
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

I think this is a comment for the proto, not pprofile. Should we file an issue at the proto repo?

Copy link
Member

Choose a reason for hiding this comment

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

Not sure I understand, what is this repeated key/value and what is the behavior if duplicates are present.

Copy link
Member Author

Choose a reason for hiding this comment

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

AttributeTable is an array of key/values meaning attributes. They are an index though, not the actual list of attributes (though everything in that index should be used by samples in the profile).
Then, each sample has an array of integers, corresponding to the index of entries in AttributeTable.

If we make it a map, we can't have duplicate keys (with different values).

As for pcommon.Slice, I'm not seeing it being used by anything else. In every signal, we define slice structs specifically.

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.

3 participants