The Python continuous profiling is currently made across 5 dimensions:
Get the Blackfire Continuous Profiler Python library:
1
pip install blackfire_conprof
The Python profiler API Profiler
can be initiated with following options:
application_name
: the application name.period
: specifies the length at which to collect CPU profiles.
The default is 45 seconds.upload_timeout
: observability data upload timeout. The default is 10 seconds.labels
: a dict containing the custom labels specific to the profile payload that is sent.The Python continuous profiler API has two functions:
1 2
def start():
def stop():
def start():
¶
The start
function starts the continuous profiler probe.
It collects profiling information in the background and periodically uploads it
to the Blackfire Agent until the stop
function is called.
def stop():
¶
Stops the continuous profiling probe.
1
pip install blackfire_conprof
1 2 3 4 5 6 7 8 9 10
from blackfire_conprof.profiler import Profiler
def foo():
import time
time.sleep(1.0)
profiler = Profiler(application_name="my-python-app", labels={'my-extra-label': 'data'})
profiler.start()
foo()
profiler.stop()
1
python example.py