Pyroscope Python integration
Project description
Pyroscope Python Package
Pyroscope integration for Python
What is Pyroscope
Pyroscope is a tool that lets you continuously profile your applications to prevent and debug performance issues in your code. It consists of a low-overhead agent which sends data to the Pyroscope server which includes a custom-built storage engine. This allows for you to store and query any applications profiling data in an extremely efficient and cost effective way.
How to install Pyroscope for Python Applications
pip install pyroscope-io
Minimal Configuration
Add the following code to your application. This code will initialize pyroscope profiler and start profiling:
import pyroscope
pyroscope.configure(
application_name = "my.python.app", # replace this with some name for your application
server_address = "http://my-pyroscope-server:4040", # replace this with the address of your pyroscope server
)
Full Configuration
Optionally, you can configure several parameters:
import pyroscope
pyroscope.configure(
application_name = "my.python.app", # replace this with some name for your application
server_address = "http://my-pyroscope-server:4040", # replace this with the address of your pyroscope server
auth_token = "{YOUR_API_KEY}", # optional, if authentication is enabled, specify the API key
sample_rate = 100, # default is 100
detect_subprocesses = False, # detect subprocesses started by the main process; default is False
oncpu = True # report cpu time only; default is True
native = False # profile native extensions; default is False
gil_only = True # only include traces for threads that are holding on to the Global Interpreter Lock; default is True
log_level = "info" # default is info, possible values: trace, debug, info, warn, error and critical
tags = {
"region": '{os.getenv("REGION")}',
}
)
Tags
You can add tags to certain parts of your code:
# You can use a wrapper:
with pyroscope.tag_wrapper({ "controller": "slow_controller_i_want_to_profile" }):
slow_code()
Example
Check out this example python project in our repository for examples of how you can use these features.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for pyroscope_io-0.8.5-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 451f47753a92efc6e0645f6280e8e2586c27414baff40fea8bac2db8570f0283 |
|
MD5 | 597ba75a205f2c2f4574947dd30b1ab2 |
|
BLAKE2b-256 | 9b1e569eac6e0e1d9e28dee93933284a52608c57fae91e33a2d5a2cbfdfb6494 |
Hashes for pyroscope_io-0.8.5-py2.py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2efef45a64ae4c064c3c1a7228bfad43d6223172b92b62b1f8464c72d42387d9 |
|
MD5 | 29d8c3fc642481d4e59f5f1eea16de38 |
|
BLAKE2b-256 | fbc409f15db3cfb1b36b202640237500bccc4d278284be6a8bd0e84d1212b65b |
Hashes for pyroscope_io-0.8.5-py2.py3-none-macosx_11_0_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 95b5356af323c401bbe7163179a2a87227322df2b6add8717913eb9d3436728e |
|
MD5 | a74eea2603e05fb2f615d2cd84d63602 |
|
BLAKE2b-256 | 8db61b1678223181df9818c9f086f53df1828f1fd58a35edb584371f5390c757 |
Hashes for pyroscope_io-0.8.5-py2.py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b9067a3dfb8bef9af87066f06b57831195d73d000741558b9c89fa41496f19c |
|
MD5 | 42bc6e06a27fe2e047775d9994f8c870 |
|
BLAKE2b-256 | 1de311a5ae45abca926813d2d0fc9ae51481b54f9eac6e8faa48165285012355 |