Skip to main content

Blackfire Continuous Profiler

Project description

Blackfire Continuous Profiler for Python

Blackfire Continuous Profiler continuously collects and uploads profiling data to the Blackfire servers. Once enabled, the profiler collects the relevant profiling information in configurable intervals and periodically uploads it to the Blackfire Agent. Blackfire Agent then forwards this information to the backend.

How to use

Prerequisites

  • Python >= 3.7.0
  • Blackfire Agent >= 2.13.0

Installation

pip install blackfire_conprof

Example

An example using the whole API interface:

  1. Install dependencies
pip install blackfire_conprof
  1. Create example.py with the following code
from blackfire_conprof.profiler import Profiler

def foo():
    import time
    time.sleep(1.0)

profiler = Profiler(application_name="my-python-app", agent_socket="tcp://127.0.0.1:8307", labels={'my-extra-label': 'data'})
profiler.start()
foo()
profiler.stop()
  1. Run Blackfire Agent (version 2.13.0 and up)
BLACKFIRE_SOCKET="tcp://127.0.0.1:8307" blackfire agent --log-level=4
  1. Run the example application. (python example.py)
  2. Profiler will send data to the Agent, and Agent will forward it to the Blackfire backend. Data then can be visualized at https://blackfire.io

Enabling the profiler

There are two ways to enable the profiler:

  • via Code,
  • via Command Line.

Code

from blackfire_conprof.profiler import Profiler

profiler = Profiler()
profiler.start()

If you are working with gevent or any other library that uses pseudo-threads, and you also need to call

import blackfire_conprof.auto

as early as possible in your application. Example: for gevent applications to work correctly, this needs to be imported before gevent.monkey.patch_all().

Command line

Run your Python application as following:

blackfire-conprof python app.py

This will automatically enable the profiler just before your application runs.

Contributing

Use make help to display an overview of useful commands for your dev environment.

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

blackfire_conprof-1.2.3-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file blackfire_conprof-1.2.3-py3-none-any.whl.

File metadata

  • Download URL: blackfire_conprof-1.2.3-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.15.0 pkginfo/1.12.0 requests/2.32.3 setuptools/45.2.0 requests-toolbelt/1.0.0 tqdm/4.67.1 CPython/3.8.10

File hashes

Hashes for blackfire_conprof-1.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 eaa5273eb0c21c096b06bf9423517017f6831aa6d139cdd15e8d43f893de722c
MD5 21aea86c64c01024245ad4441d710859
BLAKE2b-256 0c62b66fb446b5b80d4890474ae510845cbffde5a3679cbcf6b1e232aba7b21b

See more details on using hashes here.

Supported by

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