-
Notifications
You must be signed in to change notification settings - Fork 439
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
Use as a library #110
Comments
This change lets py-spy be used as a rust library. This allows you to write rust code to connect to a python program and take a stack trace from it. Most of this change is in adding some basic documentation on how to do this, and adding a src/lib.rs that exports a couple of the core py-spy classes. Note that we're only exposing a very minimal set of functionality right now, and leaving things like the consoleviewer/flamegraph code out of this library. #110
Thanks! I think this is a great idea, and just exposing as a rust library isn't a big change at all. You can use py-spy 0.1.11 as a library with that last PR (#126). The exposed API is pretty basic and only covers the core use case of getting samples from a target process, and doesn't include things like the flamegraph/console code . The API's here might change a bit until we hit a 1.0 release, but by limiting the exposed public API I'm hoping to minimize breaking changes to anyone that might use this crate. I've created an example https://github.com/benfred/py-spy/blob/master/examples/dump_traces.rs that shows how to use this, and there is some very basic documentation on the exposed API's here https://docs.rs/py-spy/0.1.11/py_spy/ I've also been thinking about exposing a python api w/ py03 (and even wrote up a blog post about the approach last year) - but exposing py-spy as a rust library will let anyone who is interested build the python bindings themselves using the steps in that post. edit: moved repo to file in examples/ folder |
This change lets py-spy be used as a rust library. This allows you to write rust code to connect to a python program and take a stack trace from it. Most of this change is in adding some basic documentation on how to do this, and adding a src/lib.rs that exports a couple of the core py-spy classes. Note that we're only exposing a very minimal set of functionality right now, and leaving things like the consoleviewer/flamegraph code out of this library. benfred/py-spy#110
Similar to #74 – for building infrastructure on top of py-spy it would be nice if there was a supported programmatic API for using py-spy functionality from a larger Rust program.
(In my case, I was thinking of taking occasional samples from running processes and logging them to a central database for "global profiling" analysis across many machines and a long time period.)
The text was updated successfully, but these errors were encountered: