Python Agent API

The New Relic 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 New Relic Python agent API overview.

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_user_attribute
(Deprecated.) Adds a custom attribute to a transaction.
application
Returns object corresponding to a New Relic-monitored app; required by some Python agent API calls.
application_settings
Returns an application settings object.
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 New Relic 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 New Relic Browser footer for injecting the JavaScript agent.
get_browser_timing_header
Generates New Relic Browser header for injecting the JavaScript agent.
global_settings
This call returns a reference to the New Relic 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.
message_trace
Report messaging functions as transaction trace segments.
message_transaction
Report message functions to New Relic as transactions.
record_custom_event
Records a custom event for use in New Relic Insights.
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.
wsgi_application
Monitor web transactions by marking the WSGI application entry point.