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

Display class name ? #722

Open
ocervell opened this issue Nov 2, 2024 · 1 comment
Open

Display class name ? #722

ocervell opened this issue Nov 2, 2024 · 1 comment

Comments

@ocervell
Copy link

ocervell commented Nov 2, 2024

Hi,

Would it be possible to have an option to display the class name when calling class / instance methods ?

Let me explain my use case for https://github.com/freelabz/secator:

I have a base class Runner and many derived classes that each have their own name (httpx, naabu, nmap, ...) and implement the yielder() function differently. My goal is to get precise profiling information about each of those derived classes.

In my flamegraph, I'm seeing the same function yielder take a lot of time, but I can't distinguish between the derived classes other than by the order they are run at.

pyinstrument gives me httpx.yielder, nmap.yielder, etc... which makes it easy to understand what's going on, but py-spy only gives me the function name. I like py-spy because it supports multi-threading, but without this feature I don't have a clear view on my app.

@Jongy
Copy link
Contributor

Jongy commented Nov 10, 2024

In PyPerf we've implemented "class name" by checking if the first arg of a function is called self / cls. If self, we deref the arg's type (and if cls we assume it's the type) and then we read the type's name. This is implemented here in BPF, and can be added to py-spy easily.

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

No branches or pull requests

2 participants