Crates.io | pyroscope-cli |
lib.rs | pyroscope-cli |
version | 0.2.0 |
source | src |
created_at | 2022-03-30 17:12:00.441112 |
updated_at | 2022-05-04 11:03:03.743393 |
description | Pyroscope Profiler CLI |
homepage | https://pyroscope.io |
repository | https://github.com/pyroscope-io/pyroscope-rs |
max_upload_size | |
id | 559298 |
size | 131,391 |
pyroscope-cli
is a general purpose profiler. It currently supports profiling ruby and python applications. The aggregated data from profiling is then sent to a Pyroscope Server. Under the hood, it uses the Pyroscope Rust library and its backends.
This is a Work-in-Progress implementation. Some features (like adhoc/pull mode) are still not available and the profiling spies are limited to Ruby/Python. For the original implementation, you should check the Pyroscope Go agent.
Please see the CHANGELOG for a release history.
Currently, the best method to locally install pyrsocope-cli
is to use the rustc compiler with Cargo.
$ cargo install pyrsocope-cli
Binaries are also available in the Release page. The targeted platforms are x86_64
/ARM
and linux
/macos
.
There are two options to profile programs, regardless of the profiler: Either by connecting to the process PID, or by passing a command where the agent will handle both its execution and profiling.
$ pyroscope-cli connect --pid=$pid --spy-name=rbspy
$ pyroscope-cli exec --spy-name=rbspy ruby ./program.rb
To connect to a process and attach a profiler, you'll need both a PID and the required system privileges. The last one will vary depending on your Operating System and its configuration.
To get the PID of a program, you can use ps
and grep
:
$ ps -aux | grep ruby
You also need to specify the profiler, the possible values are rbspy (for Ruby) and pyspy (for Python). The pid
and spy-name
are the two required arguments to profile a process.
$ pyroscope-cli connect --pid=1222 --spy-name=rbspy
pyroscope-cli
can execute a command and profile the spawned process. The command is spawned as a child of the agent process. Once the agent process exits, the executed command its child processes exit too.
$ pyroscope-cli exec --spy-name=rbspy ruby ./program.rb
You can also pass arguments to the executed command by appending --
$ pyroscope-cli exec --spy-name=rbspy ruby ./program.rb -- --ruby-arg=value
Both the pyroscope-cli agent, and its backend profilers can accept configuration. Some options are accepted by all profilers, while other can only apply to a certain profiler or a multiple of them. The CLI --help
menu should give a detailed list of all options that the program can accept.
info
. For more information, check logging.100
http://localhost:4040
.exec
commandThere are 3 ways to configure Pyroscope Agent. Configuration precedence is evaluated in the following order: environment variables > configuration files > command-line arguments.
Configuration files are stored in TOML format. You can specify configuration file location with -config <path>
. This is supported for both exec
and connect
commands.
pyroscope-cli -c -config /tmp/custom-config.toml <COMMAND>
Environment variables must have PYROSCOPE_
prefix and be in UPPER_SNAKE_CASE format, for example:
PYROSCOPE_APPLICATION_NAME=:my-ruby-app pyroscope-cli connect --pid=100 --spy-name=rbspy
Logs are output to the terminal. There are 6 levels of logging. Log levels are not displayed seperately but rather takes precedence. For example, if you specify the info
log level, you'll get output for info
, warn
, error
and critical
logs.
The rbspy
profiler can be used to profile Ruby application. It uses the rbspy backend, which itself is a wrapper around the rbspy profiler.
The pyspy
profiler can be used to profile Ruby application. It uses the pyspy backend, which itself is a wrapper around the py-spy profiler.
Please see the FAQ page for Frequently Asked Questions.
pyroscope-cli
supports shell auto-completion for bash
, zsh
, fish
, and powershell
. You can generate the auto-completion file using the completion
command.
For example, to generate auto-complete for fish
:
$ pyroscope-cli completion fish > pyroscope-cli.fish
You can build pyroscope-cli
from source if you have a Rust toolchain installed. You will need Rust 1.59 or newer.
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
For other systems, please check the instructions at https://rustup.rs/.
. "$HOME/.cargo/env"
pyroscope-cli
git clone https://github.com/pyroscope-io/pyroscope-rs
cd pyroscope-rs/pyroscope_cli
cargo build --release
./target/release/pyroscope-cli --help
Pyroscope is distributed under the Apache License (Version 2.0).
See LICENSE for details.