Python Configuration Pythonbeta

Configuring the Probe via Environment Variables

The preferred way to configure the Python probe is via environment variables. That allows to change the configuration without modifying your code:

  • BLACKFIRE_CLIENT_ID

    Sets the client ID from the Client ID/Client Token credentials pair.

    Please log in or sign up first:

    or

  • BLACKFIRE_CLIENT_TOKEN

    Sets the client Token from the Client ID/Client Token credentials pair.

    Please log in or sign up first:

    or

  • BLACKFIRE_LOG_LEVEL

    Sets the verbosity of Probe’s log output. Default value is 1 (error).

    1
    2
    # 1: error, 2: warning, 3: info, 4: debug
    BLACKFIRE_LOG_LEVEL=1
    
  • BLACKFIRE_LOG_FILE

    Sets the output destination of Probe’s log. Default value is empty.

    1
    BLACKFIRE_LOG_FILE="/tmp/probe.log"
    
  • BLACKFIRE_AGENT_SOCKET

    Sets the socket the Probe will contact the Agent on. Possible values can be a unix socket or a TCP address.

    The default value is platform dependent, as detailed below.

    On Linux:

    1
    BLACKFIRE_AGENT_SOCKET="unix:///var/run/blackfire/agent.sock"
    

    On macOS:

    1
    BLACKFIRE_AGENT_SOCKET="unix:///usr/local/var/run/blackfire-agent.sock"
    

    On Windows:

    1
    BLACKFIRE_AGENT_SOCKET="tcp://127.0.0.1:8307"
    
  • BLACKFIRE_AGENT_TIMEOUT

    Sets the timeout, in seconds, after which the Probe will drop the connection to the Agent. Default value is 0.25, which means 250ms.

    1
    BLACKFIRE_AGENT_TIMEOUT="0.25"
    
  • BLACKFIRE_ENDPOINT

    Sets the API endpoint the profile data will be sent to.

    1
    BLACKFIRE_ENDPOINT="https://blackfire.io"
    
  • BLACKFIRE_SERVER_ID / BLACKFIRE_SERVER_TOKEN

    Sets the server id and server token used to authenticate with Blackfire. This is optional, and should be use only if you have a shared agent between multiple environments.

    or to display your Blackfire's credentials.

You can set these environment variables in a project’s local .env file if supported, or in your global shell configuration file (such as ~/.bashrc or ~/.zshrc):

1
2
3
4
export BLACKFIRE_CLIENT_ID=xxx
export BLACKFIRE_CLIENT_TOKEN=yyy
export BLACKFIRE_LOG_LEVEL=4
export BLACKFIRE_LOG_FILE=/tmp/probe.log

Configuring the Probe via the Blackfire CLI Configuration File

When environment variables are not set, the probe reads its default configuration from the configuration of the Blackfire CLI. The location of this file depends on the operating system you use. Read more about the CLI configuration.

Configuring the Probe via Python Code

You can also configure the probe from your Python code.