Skip to main content

Pyroscope Python integration

Project description

Pyroscope Python Package

Pyroscope integration for Python

license tests build PyPI version PyPI


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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyroscope-io-0.8.5.tar.gz (29.6 kB view hashes)

Uploaded Source

Built Distributions

pyroscope_io-0.8.5-py2.py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (2.9 MB view hashes)

Uploaded Python 2 Python 3 manylinux: glibc 2.17+ ARM64

pyroscope_io-0.8.5-py2.py3-none-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (3.6 MB view hashes)

Uploaded Python 2 Python 3 manylinux: glibc 2.12+ x86-64

pyroscope_io-0.8.5-py2.py3-none-macosx_11_0_x86_64.whl (2.2 MB view hashes)

Uploaded Python 2 Python 3 macOS 11.0+ x86-64

pyroscope_io-0.8.5-py2.py3-none-macosx_11_0_arm64.whl (2.2 MB view hashes)

Uploaded Python 2 Python 3 macOS 11.0+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page