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

[Feature request] Tracking of Django management commands #34

Open
caleb15 opened this issue Sep 27, 2022 · 4 comments
Open

[Feature request] Tracking of Django management commands #34

caleb15 opened this issue Sep 27, 2022 · 4 comments

Comments

@caleb15
Copy link

caleb15 commented Sep 27, 2022

At 15Five we have a ton of django management commands, it would be cool if they were also tracked so we could use Kolo to better understand the code behind the command.

@caleb15
Copy link
Author

caleb15 commented Sep 27, 2022

by tracked I mean show up in sidebar, see performance details, variables, etc...

@wilhelmklopp
Copy link
Member

@caleb15 I have good news. Tracing things other than requests (like management commands, tests, and also small blocks of code) has been in the works for months and we officially support it as of the v2 release a few weeks ago.

You should be able to do kolo run python manage.py my_management_command and once the command has finished running it will show in in the sidebar 🎉

We're in the process of improving our docs, but there's a bit more context here: https://docs.kolo.app/en/latest/kolo-run.html

We also now have a @kolo.enable decorator and a with kolo.enabled() context manager to trace smaller, specific blocks of code: https://docs.kolo.app/en/latest/kolo-enabled.html

@caleb15
Copy link
Author

caleb15 commented Sep 29, 2022

Sweet! I just tried running it. Here are my impressions.

  1. ✔️ Like you said, just kolo run .... Very easy to do.
  2. ✔️ Data immediately shows up, which is nice
  3. 🐛 But for some reason it's not labeled with the name of the management command.
    image
    ff/core/types is a file that's in the import chain from loading ff/__init__.py. It's not the file that has the code for the management command. I would expect the run to preferably by labeled by the name of the management command but the filepath to the file with the management command code would also work.
  4. 🐛 With over 19,000 frames, searching manually for the frame I'm interested in is a struggle. I tried the control-f sidebar search, but still didn't find the file I was looking for. This is odd because I see the logs in Kolo, so it definitely got executed. Also I see that the management command handle function that calls the function I'm interested in got tracked, just not the function itself. Finally I see the frame in the raw trace, so it looks like the issue might be with the visualization of the trace. Or maybe I'm just failing to find it on my end.

Example of searching through frames
image

  1. I see the logs ✔️ . It would be really nice if the logs had a link to the filepath:linenumber where the log occurred.
  2. I see the SQL queries ✔️
  3. The background jobs appear in the sidebar ✔️ , but clicking on them doesn't do anything.
  4. HTTP requests appear ✔️ , and show the truncated request body in the sidebar ✔️ , but clicking on it does not open up a window showing the full body 🐛 . I'm not sure if this is implemented yet, but it would be nice to be able to go from a HTTP request to the code where the call was made.

image

  1. 🐛 Because there's so many frames, the visualization is very slow and really eats up CPU.

Overall it's a promising start but some work is needed for large codebases. I'm excited to see what improvements you make :)
I know I just threw a lot of information at you, so I'm happy to hop on a call or DM you more debug info if you want.

@caleb15
Copy link
Author

caleb15 commented Sep 29, 2022

We also now have a @kolo.enable decorator and a with kolo.enabled() context manager to trace smaller, specific blocks of code: https://docs.kolo.app/en/latest/kolo-enabled.html

Thanks for this, I was able to use this as a workaround 🙂 . I enabled the function I was looking for and just ran the management command normally. The function appeared in Kolo, and the massive frame count was significantly reduced down to 5962. The performance of the visualizer is workable now, although still slow. It's really cool to see all the calls in the visualizer.

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