Python agent API

The Python agent API allows you to set up custom instrumentation and performance monitoring of your Python application. For an introduction to the API and tips for accomplishing specific tasks, see the Python agent API overview.

accept_distributed_trace_headers
This method is used for accepting the headers used to connect transactions within a distributed trace.
accept_distributed_trace_payload
This method is used for accepting the payloads used to connect transactions within a distributed trace.
add_custom_parameter
Adds a custom attribute to a transaction.
add_custom_parameters
Adds one or more custom attributes to a transaction.
add_custom_span_attribute
Adds a custom attribute to a span event.
application
Returns object corresponding to an agent monitored app; required by some Python agent API calls.
application_settings
Returns an application settings object.
asgi_application
Monitor web transactions by marking the ASGI application entry point.
background_task
Used to instrument a background task or other non-web transaction.
callable_name
Returns a string name identifying the supplied object.
capture_request_params
Enables capture of a transaction's query string parameters.
create_distributed_trace_payload
This method is used for generating payloads used to connect transactions within a distributed trace.
current_transaction
Returns an object corresponding to the current transaction.
datastore_trace
Used to instrument calls to datastores.
data_source_factory
Wraps a data source defined as a factory.
data_source_generator
Wraps a metric-data-generating data source.
disable_browser_autorum
Disables Browser monitoring for a web request.
end_of_transaction
Ends the current transaction.
external_trace
Report calls to external services as transaction trace segments.
function_trace
Used to instrument functions, methods, generators, and coroutines that aren't instrumented by default.
Generates a browser agent footer for injecting the JavaScript agent.
get_browser_timing_header
Generates a browser agent header for injecting the JavaScript agent.
get_linking_metadata
Returns a dictionary of contextual data for use in log messages.
global_settings
This call returns a reference to the Python agent's global settings object.
ignore_transaction
Ignores the current transaction.
initialize
Initializes the Python agent with a specified config file during a manual integration process.
insert_distributed_trace_headers
This method is used for inserting headers used to connect transactions within a distributed trace.
message_trace
Report messaging functions as transaction trace segments.
message_transaction
Report message functions as transactions.
record_custom_event
Records a custom event for use in querying
record_custom_metric
Records a single custom metric.
record_custom_metrics
Records a set of custom metrics.
record_exception
Records details of a Python exception as an error.
register_application
Registers the Python agent immediately. Used for manual initialization of agent.
register_data_source
Registers a data source for generating custom metric data.
set_background_task
Marks a transaction as a "background task."
set_transaction_name
Sets the name of the current transaction.
shutdown_agent
Forcibly shuts down the agent.
suppress_apdex_metric
Prevents the current transaction from contributing to Apdex.
suppress_transaction_trace
Prevents the current transaction from generating a transaction trace.
web_transaction
Used to instrument a web transaction.
wsgi_application
Monitor web transactions by marking the WSGI application entry point.