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

fix: export of custom pprof labels #2667

Closed
wants to merge 1 commit into from
Closed

Conversation

teleivo
Copy link
Contributor

@teleivo teleivo commented Feb 28, 2023

work in progress to fix #2657

  • Add missing pprof_labels to the downloaded profile. Fix written by @brancz in https://github.com/parca-dev/parca/compare/pprof-labels-poc 😄
  • Normalization of labels is done in two places. Label normalization before ingest was adding the collision prefix 'exported_' even if no collision was present.
  • Adapted pkg/parcacol/normalizer_test.go setup data as it did not seem to reflect reality. The stringTable does not contain the takenLabels key/values when running parca. stringTable only contains strings from the profile. In case of a collision, the colliding key will be in the stringTable due to it being in the profile. In such a case it is not prefixed with exported_ as this is done by parca.

Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

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

This is going into a really awesome direction, thank you so much for taking a stab at this!!

pkg/parcacol/querier.go Outdated Show resolved Hide resolved
@@ -102,7 +107,8 @@ func (q *Querier) Labels(
}

val := stringCol.Value(i)
seen[strings.TrimPrefix(val, "labels.")] = struct{}{}
l := strings.TrimPrefix(strings.TrimPrefix(val, ColumnLabelsPrefix), ColumnPprofLabelsPrefix)
Copy link
Member

Choose a reason for hiding this comment

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

based on the prefix we can tell what kind of profile it is and return that to the frontend, and only the frontend will unify it into a single list

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 don't quite understand 😄

I assumed that since we removed the prefix for labels. we should do the same irrespective of where the prefix comes from.

Do you mean we should only trim the labels. prefix and the frontend is going to take care of removing the pprof_labels. prefix?

Copy link
Member

Choose a reason for hiding this comment

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

I mean that the response should have one list that is pprof_labels, and one that is regular labels. That way the frontend will be able to tell whether a label is a profile label or a regular one, but to the user it will only show a single list.

The reason we need this knowledge in the frontend is to be able to tell the LabelValues request, whether a label is a pprof label or a regular label.

pkg/parcacol/querier.go Outdated Show resolved Hide resolved
if err != nil {
return nil, err
}
return logicalplan.Or(labelExpr, pprofLabelExpr), nil
Copy link
Member

Choose a reason for hiding this comment

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

Like I said on Discord, I'm not sure this is quite correct, we actually need to say something like "label.a exists and is equal to "b" and pprof_labels.a does not exist OR pprof.labels_a exists and is equal to "b" and labels.a does not exist"

Unfortunately, frostdb doesn't support this yet.

I think we can leave this part for last though, we might have it implemented by the time we fix all the other things! :)

pkg/query/pprof.go Outdated Show resolved Hide resolved
@brancz
Copy link
Member

brancz commented Mar 14, 2023

Created polarsignals/frostdb#394 and added it to the team's backlog so we'll hopefully have the last missing piece for this soon! Thanks for bearing with us!

@brancz
Copy link
Member

brancz commented Mar 17, 2023

polarsignals/frostdb#394 is implemented so we can now build the queries we want to here! 🥳

Copy link
Member

@brancz brancz left a comment

Choose a reason for hiding this comment

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

I personally think we can leave the LabelNames and LabelValues calls out for now and leave them with the current behavior, and handle that in a follow-up, this is difficult enough without those :D your choice though

@@ -102,7 +107,8 @@ func (q *Querier) Labels(
}

val := stringCol.Value(i)
seen[strings.TrimPrefix(val, "labels.")] = struct{}{}
l := strings.TrimPrefix(strings.TrimPrefix(val, ColumnLabelsPrefix), ColumnPprofLabelsPrefix)
Copy link
Member

Choose a reason for hiding this comment

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

I mean that the response should have one list that is pprof_labels, and one that is regular labels. That way the frontend will be able to tell whether a label is a profile label or a regular one, but to the user it will only show a single list.

The reason we need this knowledge in the frontend is to be able to tell the LabelValues request, whether a label is a pprof label or a regular label.

pkg/parcacol/normalizer.go Show resolved Hide resolved
pkg/parcacol/normalizer.go Show resolved Hide resolved
@teleivo teleivo changed the title fix: allow querying by custom pprof labels fix: export of custom pprof labels Mar 28, 2023
Normalization of labels is done twice. Label normalization before
ingest was adding the collision prefix 'exported_' even if no collision
was present.
samples: []*pprofpb.Sample{
{
Label: []*pprofpb.Label{{
Key: 3,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@brancz I just want to make sure I get this right 😅 I added some missing tests based on the ones that were already here. The order in colliding labels in descending order refers to the order of the []*pprofpb.Label right? So the label.Key in descending order is method, instance in this case and reversed in the ascending case.

@teleivo teleivo requested a review from brancz March 29, 2023 03:48
@brancz
Copy link
Member

brancz commented Jun 26, 2023

Just rebased and tested this, and it works flawlessly. I'd be happy to merge this!

@brancz
Copy link
Member

brancz commented Jun 28, 2023

Superseeded by #3365

Thank you so much for writing this code @teleivo!

@brancz brancz closed this Jun 28, 2023
@teleivo teleivo deleted the 2657 branch July 4, 2023 04:47
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.

cpu profiler labels don't show up in parca
2 participants