Instrumented Python packages

This documentation lists the packages and modules automatically instrumented by the New Relic Python agent. For install instructions, see Install the agent.

You can disable instrumentation for specific packages or modules if the instrumentation interferes with your app. For further details on disabling the provided instrumentation see the documentation on agent configuration.

If you are using a third party package or module which is not instrumented, or you want more specific instrumentation for your own code, you can use custom instrumentation to track the time spent in additional functions. For more information, see Python custom instrumentation.

If there is a package for which you would like to request built-in instrumentation, get support at support.newrelic.com.

Web frameworks

aiohttp

Function timing in transactions traces for slow transactions is provided for:

  • View functions (coroutines).
  • Application middleware.

Exception logging is provided for:

  • Uncaught exceptions resulting in a non-200 HTTP response.

The web transaction is named after the view function.

Bottle

Function timing in transactions traces for slow transactions is provided for:

  • View function.
  • Template rendering via SimpleTemplate, MakoTemplate, CheetahTemplate, Jinja2Template and SimpleTalTemplate interfaces.

Exception logging is provided for:

  • Uncaught exceptions which would otherwise generate 500 responses from Bottle.

The web transaction is named after the view function.

As Bottle uses external template libraries, see also which of those packages may be supported for additional detail.

CherryPy

Function timing in transactions traces for slow transactions is provided for:

  • Handler function.

Exception logging is provided for:

  • Uncaught exceptions which would otherwise generate 500 responses from CherryPy.

The web transaction is named after the handler function.

As CherryPy relies upon external template libraries, see also which of those packages may be supported for additional detail.

Django

Function timing in transactions traces for slow transactions is provided for:

  • Request middleware.
  • View middleware.
  • Template response middleware.
  • Response middleware.
  • Exception middleware.
  • Template rendering.

Exception logging is provided for:

  • Exceptions occurring during loading of view handlers by URL resolver.
  • Exceptions occurring within the execution of the view handler.
  • Uncaught exceptions which would otherwise generate 500 responses from Django.

Page load timing (sometimes referred to as real user monitoring or RUM) support consists of:

  • Optional automatic insertion of JavaScript header/footer via response middleware.
  • Provision of template tag library to enable manual insertion of the JavaScript header/footer into templates.

The web transaction is named after the view handler, unless a request or view middleware returns a response object prior to the view handler being invoked.

Instrumentation is also implemented to provide better web transaction naming or additional functional tracing when using:

Flask

Function timing in transactions traces for slow transactions is provided for:

  • View function.
  • Template rendering via render_template() and render_template_string().

Exception logging is provided for:

  • Uncaught exceptions which would otherwise generate 500 responses from Flask.

The web transaction is named after the view function.

As Flask uses Jinja2 for templates, see also details of Jinja2 instrumentation listed below.

Pylons

Function timing in transactions traces for slow transactions is provided for:

  • Controller function, before and after methods.
  • Template rendering via render_genshi(), render_jinja2() and render_mako().

Exception logging is provided for:

  • Uncaught exceptions which would otherwise generate 500 responses from Pylons.

The web transaction is named after the controller/action.

As Pylons can use Genshi, Jinja2 or Mako for templates see also details of instrumentation for those modules listed below.

Pyramid

Function timing in transactions traces for slow transactions is provided for:

  • View handler functions.

Exception logging is provided for:

  • Uncaught exceptions which would otherwise generate 500 responses from Pyramid.

The web transaction is named after the view handler.

Web2py

Function timing in transactions traces for slow transactions is provided for:

  • Overall time in models phase.
  • Overall time in controller phase.
  • Overall time in view phase.
  • Execution time for specific scripts executed within models, controller and view phases.

Exception logging is provided for:

  • Uncaught exceptions which would otherwise generate 500 responses from Web2py.

The web transaction is named after the view script.

Back-end services

gearman

Timing of task execution performed in a gearman worker recorded as background tasks against designated web application. Timing as a web external any client side calls to a gearman server to queue up or wait for the execution of queued tasks.

Celery

Timing of task execution recorded as background tasks against designated web application.

Template rendering

Genshi

Function timing in transactions traces for slow transactions is provided for:

  • Template rendering.
Jinja2

Function timing in transactions traces for slow transactions is provided for:

  • Template compilation.
  • Template rendering.
Mako

Function timing in transactions traces for slow transactions is provided for:

  • Template rendering.

Instance details

New Relic collects instance details for a variety of databases and database drivers. The ability to view specific instances and the types of database information in New Relic APM depends on your New Relic agent version.

New Relic's Python agent version 2.72.0.52 or higher supports the following:

Database Python package name Minimum package version Minimum agent version
PostgreSQL psycopg2 2.0.14 2.72.0.52
MySQL MySQLdb 1.2.5 2.74.0.54
Redis redis 2.6.2 2.74.0.54
Memcached python-memcached 1.51 2.76.0.55
Elasticsearch elasticsearch 0.45 2.78.0.56

To request instance-level information from datastores currently not listed for your New Relic agent, get support at support.newrelic.com.

SQL database adapters

For Python DB-API 2.0 compliant modules listed in this section, New Relic's Python agent supports:

  • Timing of database queries
  • Capturing SQL for the database query
  • Capturing a stack trace for long database queries
  • MySQL and PostgreSQ only: Capturing explain plans for slow database queries

The Python agent should be able to track database queries for any Python DB-API 2.0 compliant modules. However, New Relic only officially supports the modules listed here. If you use a different database client module, contact support.newrelic.com. New Relic Support may be able to suggest a temporary change to your config file to get it working.

For database adapters listed with an asterisk (*), New Relic provides additional instrumentation for functionality outside of the DB-API 2.0 specification, such as shortcut methods to execute queries without creating cursors.

NoSQL database clients

Timing of calls made against NoSQL databases are provided for the following client modules.

Elasticsearch clients

Time spent in calls made to Elasticsearch will be listed in both the main overview chart, as well as in the Databases tab in the UI.

Memcache clients

Timing of memcache requests and capture of type of request is provided for the following memcache client modules.

Solr service clients

Timing of Solr service requests and type of request is provided for the following Solr client modules.

Message broker clients

Timing of message broker transactions is provided for the following modules.

External web services

Timing of external web service requests is carried out via the following modules.

For more help

Recommendations for learning more: