Start and Stop Agent

init(environ=None,timeout_ms=NO_TIMEOUT)

Initializes the Python Agent.

Call this function at the very beginning of your instrumented application, preferably before any other imports and before creating any other threads.

Agent initialization occurs asynchronously. init() returns immediately if no timeout is specified but it is possible that the agent will not immediately be ready to report business transactions. In this case, the start_bt() method will return None.

This function will never raise an exception.

Returns True if the agent is properly configured, False if the agent is not properly configured.

To be properly configured the agent configuration file must contain the minimal settings and possibly some additional settings if they are required for your environment. See Configure the Agent in Install the Python Agent for the minimal settings and Python Agent Settings for the complete list.

environ: dict, optional

If specified, a dictionary of environment variables to use to override the agent's configuration, derived from the actual OS environment variables.

timeout_ms: int or None, optional

Timeout interval in milliseconds.

By default, init() returns immediately, even if the Python agent has not received its configuration from the controller. If timeout_ms is None, init() blocks until the agent is properly configured. Otherwise, init() waits for up to timeout_ms for agent to become properly configured.

shutdown(timeout_ms=None)

Shuts down the Python Agent. The agent stops reporting metrics to the Controller.

This function ends all active business transactions and waits for them to finish reporting to the controller before returning.

timeout_ms: int, optional

By default, this function waits until all pending business transactions have been reported before returning. If timeout_ms is set, this function will return after timeout_ms, regardless of whether all business transactions have been reported.