Skip to content

refactor(profiling): type pprof exporter and fix type comparison (backport #2987) #3062

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

Merged
merged 1 commit into from
Dec 10, 2021

Conversation

mergify[bot]
Copy link
Contributor

@mergify mergify bot commented Dec 10, 2021

This is an automatic backport of pull request #2987 done by Mergify.


Mergify commands and options

More conditions and actions can be found in the documentation.

You can also trigger Mergify actions by commenting on this pull request:

  • @Mergifyio refresh will re-evaluate the rules
  • @Mergifyio rebase will rebase this PR on its base branch
  • @Mergifyio update will merge the base branch into this PR
  • @Mergifyio backport <destination> will backport this PR on <destination> branch

Additionally, on Mergify dashboard you can:

  • look at your merge queues
  • generate the Mergify configuration with the config editor.

Finally, you can contact us on https://mergify.com

There was an ongoing issue wih the pprof encode mixing type between strings,
ints and None when dealing with labels. This has been fixed in multiple places
and in multiple occasion, but there were still holes.

When encoding Events to pprof, they are grouped by event fields. Those fields
might be str, int or something else. In order to group those events, all the
fields used for grouping must be:

1. hashable (because we index in a dict)
2. sortable (because we sort event to have reproducible)
3. string (because we store those as labels in pprof)

The problem is that most value type used in events are hashable (None, int or
str) but sortability often fails when one of the field is None: you can't
compare `int` with `None`, making sorted() call fails like in #2962.

As we need string in the end, the fix is to convert everything to strings as
soon as possible when grouping events: that makes sure conditions 1, 2 and 3
are validated ASAP and everything works.

To do this, the code has been updated and typed to catch any future error.

Fixes #2962

Co-authored-by: Brett Langdon <[email protected]>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
(cherry picked from commit 6520212)
@mergify mergify bot requested a review from a team as a code owner December 10, 2021 15:35
@jd jd added the changelog/no-changelog A changelog entry is not required for this PR. label Dec 10, 2021
@codecov-commenter
Copy link

Codecov Report

Merging #3062 (20630f4) into 0.56 (0e4db42) will decrease coverage by 0.03%.
The diff coverage is 5.68%.

Impacted file tree graph

@@            Coverage Diff             @@
##             0.56    #3062      +/-   ##
==========================================
- Coverage   84.37%   84.34%   -0.04%     
==========================================
  Files         623      624       +1     
  Lines       45312    45337      +25     
==========================================
+ Hits        38234    38238       +4     
- Misses       7078     7099      +21     
Impacted Files Coverage Δ
ddtrace/profiling/collector/memalloc.py 0.00% <0.00%> (ø)
ddtrace/profiling/collector/stack_event.py 0.00% <0.00%> (ø)
ddtrace/profiling/collector/threading.py 0.00% <0.00%> (ø)
ddtrace/profiling/event.py 0.00% <0.00%> (ø)
ddtrace/profiling/exporter/__init__.py 0.00% <0.00%> (ø)
ddtrace/profiling/exporter/file.py 0.00% <0.00%> (ø)
ddtrace/profiling/exporter/pprof_pb2.py 0.00% <ø> (ø)
ddtrace/profiling/profiler.py 0.00% <0.00%> (ø)
ddtrace/profiling/recorder.py 0.00% <0.00%> (ø)
tests/profiling/collector/test_stack.py 0.00% <0.00%> (ø)
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update be1380e...20630f4. Read the comment docs.

@mergify mergify bot merged commit 4807a2c into 0.56 Dec 10, 2021
@mergify mergify bot deleted the mergify/bp/0.56/pr-2987 branch December 10, 2021 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog/no-changelog A changelog entry is not required for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants