Recently I stumbled upon slow library/function problem and don’t know chich part that causes it, and found out that there’s a easy way to trace either Go, Ruby, or Python code using Pyroscope. The feature is a bit minimalist, there’s no memory usage tracing yet unlike in gops or pprof. Pyroscope consist 2 parts: the server and the agent/client library (if using Golang) or executor (if using Ruby or Python). Here’s the way how to run and start Pyroscope server:
# run server using docker
docker run -it -p 4040:4040 pyroscope/pyroscope:latest server
And here’s the example on how to use the client library/agent (modifying Go’s source code, just like in DataDog or any other APM tools) and install the Pyroscope CLI to run Ruby/Python scripts:
# golang, add agent inside the source code
It would show something like this if you open the server URL (localhost:4040) in the browser, so you can check which part of the code that took most of the runtime.
Originally published at http://kokizzu.blogspot.com.