Skip to main content

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.

Under the hood, this profiler uses Datadog's dd-trace-py (pinned to v4.6.4) for profiling data collection.

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.

Metadata

Release files for blackfire-conprof 1.2.11

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distribution (wheel)

Table of built distributions (wheels) for blackfire-conprof 1.2.11
File Interpreter ABI Platform
blackfire_conprof-1.2.11-py3-none-any.whl Python 3 none any Details

Release files / blackfire_conprof-1.2.11-py3-none-any.whl

Download URL blackfire_conprof-1.2.11-py3-none-any.whl
Size 7.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f93e8515c4e8899499f16c116ec2ae18c101103d11d30a92f4e5c8d3cf7da0c
BLAKE2b-256 checksum
How to use checksums
d15492ec2546eea0933f207c57c009bbcb22c56400070f97737d00cd27fdc17c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Security for blackfire-conprof 1.2.11

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page