Notes
This release of the Python agent includes a bug fix for the mako library instrumentation.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Bug Fixes
Fixed a crash when using the Mako template library
When running with the Mako template library the agent would crash on attempting to render a template. This issue has now been corrected.
Notes
This release of the Python agent introduces:
- Event loop diagnostics feature
- Tornado instrumentation for versions 6 or higher
- Improved context manager API functionality and interfaces
This release also drops support for Python 3.4.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Event loop diagnostics
Introducing event loop diagnostics for asyncio! The Python agent can now surface information about transactions that block the event loop. The agent will be able to generate information about transactions that have waited a significant amount of time to acquire control of the event loop.
Event loop diagnostic information will be available in both APM and via NRQL query.
Event loop metrics will appear in the transaction Breakdown table:

Time spent waiting on other transactions will be shown in the transaction Trace details page, as shown here:

eventLoopTime
and eventLoopWait
attributes will be available via NRQL query. An example query might be:
SELECT count(*) as 'count', average(eventLoopTime) as 'loopTime', average(eventLoopWait) as 'loopWait' FROM Transaction facet name
In New Relic Insights, this might show a result like this:

Diagnostics will be available by default through our existing aiohttp, sanic, and Tornado instrumentation. Diagnostic information will also be available for coroutines that use our background_task and web_transaction decorator APIs.
Tornado 6 Instrumentation
Instrumentation for Tornado framework version 6.x is supported without any feature flags. Support for versions earlier than Tornado 6.x has been dropped. The Tornado web server, framework, and http client are instrumented and information will show up in both APM and insights.
Important: Using the tornado.gen.coroutine
with instrumentation is not supported. Any usage of tornado.gen.coroutine
should be replaced with an asyncio coroutine.
Before
class MainHandler(tornado.web.RequestHandler): @tornado.gen.coroutine def get(self):
yield gen.sleep(0.2)
After
class MainHandler(tornado.web.RequestHandler): @asyncio.coroutine def get(self):
yield from gen.sleep(0.2)
Improved APIs for time trace context managers
Context managers (such as FunctionTrace, ExternalTrace, DatastoreTrace) may now be used from within asyncio coroutines! Additionally, the transaction argument is no longer used for any context manager API. In order to transition to the new API, the transaction argument must be removed.
Before
transaction = newrelic.agent.current_transaction()with newrelic.agent.FunctionTrace(transaction, "my_trace"): pass
After
with newrelic.agent.FunctionTrace("my_trace"): pass
Updated WebTransaction context manager
The WebTransaction context manager is no longer WSGI dependent. The context manager takes generic HTTP arguments, which you can use to build web transactions that appear in the APM product. For more information, see our API documentation.
Notes
This release of the Python agent includes bug fixes, deprecations, and improved naming behavior for gRPC.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Feature Enhancements
Improved gRPC support
The external and transaction pages now show the gRPC method being called in addition to the host and port.
Ability to disable sending db.statement as part of traces
When db.statement is added to either attributes.exclude or transaction_segments.attributes.exclude, the value will now no longer be sent to New Relic as part of transaction traces or spans.
Deprecations
TransactionContext API is now deprecated
The TransactionContext API will be removed in a future release.
Tornado instrumentation + feature flag deprecation
The existing introductory support for Tornado and feature flags will be removed from a future release. Versions 6.x and newer will be the only versions of Tornado supported in future releases. See this discussion on the New Relic forums for more details.
Bug Fixes
Fixed a crash when using uvicorn workers with gunicorn
When running ASGI applications with gunicorn, the agent would attempt to instrument the application as a WSGI application, resulting in a crash. The agent will no longer attempt to instrument gunicorn applications that are coroutines.
Remove logging of license keys
The agent logged license keys when data failed to send to New Relic. The agent will no longer log license keys to the agent logs under any circumstance.
Fix operation of distributed tracing and cross application tracing when httplib connections are reused
When making multiple requests via a single connection with httplib, httplib2, or urllib3, the proper headers will be added to each outgoing request. As a result, cross application tracing and distributed tracing will now operate as expected when reusing connection objects.
Notes
This release of the Python agent includes bug fixes and adds new API methods to retrieve the current trace ID and current span ID.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Features
Added a new API to retrieve the current trace ID
Retrieving the current trace ID can now be accomplished with a call to
newrelic.agent.current_trace_id()
. This method will return the id of the current trace, or None if no transaction is in progress.Added a new API to retrieve the current span ID
Retrieving the current span ID can now be accomplished with a call to
newrelic.agent.current_span_id()
. This method will return the id of the current span, or None if no span is in progress.
Bug Fixes
Exclusive time incorrectly displayed when using concurrent asyncio
The New Relic UI may have shown times equaling greater than 100 percent of the total time when executing concurrent tasks in asyncio. The exclusive times reported by the agent will now be correctly displayed in APM and insights.
Notes
This release of the Python agent adds improvements to the gRPC instrumentation package and includes bug fixes.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Features
Improved gRPC support
Support for measuring inbound gRPC requests has now been added. Inbound gRPC requests will now show as web transactions in APM. Additionally, distributed tracing is now supported as part of the gRPC instrumentation package.
Bug Fixes
Update pika instrumentation to support the 1.x releases
When using the agent with pika versions 1.x and up, the agent may have caused an application crash. The agent now correctly collects data on newer versions of pika.
The startup_timeout setting may not have been honored in a multithreaded application
When startup_timeout is set to a number greater than 0, the servicing of transactions is blocked until the agent has fully activated. In multithreaded applications, only the first thread would block due to improper locking. The agent will now block on all threads.
Notes
This release of the Python agent fixes a memory leak that occurs on Python 2 when monitoring WSGI applications.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Bug Fixes
Fix memory leak on Python 2 WSGI applications
When using the 4.16.0 agent on Python 2 to monitor WSGI applications, the agent would cause memory to be allocated on each request. On Python 2, this memory was never deallocated due to a reference cycle. This has now been corrected.
Notes
This release of the Python agent adds support for native coroutines and generators with a new web_transaction API, as well as bugfixes.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Features
Add a new web_transaction API
This method is now exposed both as a public API through
newrelic.agent.api.wrap_web_transaction
, and as a decorator withnewrelic.agent.api.web_transaction
. It can be used to instrument non-WSGI web transactions. For usage of this API see https://docs.newrelic.com/docs/agents/python-agent/python-agent-api/webt...
Bug Fixes
The presence of unicode values in a SQL query on Python 2 may cause an application crash
The agent was not properly handling unicode values when recording SQL queries in Python 2. As a result, the presence of unicode values in SQL queries in Python 2 applications may have resulted in an application crash. Unicode values in Python 2 SQL queries are now properly handled.
The Python Agent may have improperly biased the random sampling of distributed traces
Distributed traces are randomly sampled across services. The agent is responsible for propagating the state of its sampling decision to other services. In propagating that decision, an improper sampling bias may have been introduced in downstream services.
The agent will no longer report the command arguments used to start newrelic-admin
The agent previously reported the startup command and arguments when using
newrelic-admin run-program
andnewrelic-admin run-python
. The command and arguments are no longer sent to New Relic. This data may continue to be logged to the agent log files when debug level logs are enabled.
Notes
This release of the Python agent adds support for native coroutines and generators with the background task API and adds support for Kubernetes detection.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Features
@background_task can now be used with coroutines
The background_task decorator API can now be used with native coroutines and generators.
@background_task(name='my_coroutine')async def my_coroutine():await asyncio.sleep(0.1)Add support for collection of Kubernetes metadata
The agent will now collect environment variables prefixed by
NEW_RELIC_METADATA_
as additional metadata. Some of this metadata may be added to Transaction events to provide context between your Kubernetes cluster and your services. For details on the benefits (currently in beta) see this blog post.The agent now also collects the
KUBERNETES_SERVICE_HOST
environment variable to detect when the application is running on Kubernetes. The data is used to link the application to the host machine when using the New Relic infrastructure product.
Bug Fixes
Using time trace decorators allowed coroutines to become Iterables and generators to become awaitables
When using time trace decorators native coroutines were converted to iterables. Additionally generators were converted to awaitables. The behavior of generators, native coroutines, and awaitable generators is now unchanged when using time trace decorators.
Notes
This release of the Python agent extends support of Amazon's boto3 library and includes bug fixes.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Features
AWS operation and request ID will now be reported in transaction traces and spans when using boto3 and botocore.
The agent will now report
aws.requestId
andaws.operation
for all calls to AWS made using botocore and boto3.DynamoDB calls are now reported under the Databases tab.
The agent will now record DynamoDB query performance in the Databases tab in APM in addition to table name for the following calls:
- put_item
- get_item
- update_item
- delete_item
- create_table
- delete_table
- query
- scan
Certain SQS calls will now report additional data for spans and transaction traces.
The agent will now record the queue name in spans and transaction traces for the following SQS calls:
- send_message
- send_message_batch
- receive_message
SNS publish will now report additional data for spans and transaction traces.
The SNS topic, target, or the string literal PhoneNumber will be reported to New Relic inside of spans and transaction traces.
The full URL path will now be recorded on span events and transaction traces when using boto3 or botocore.
The agent will now record the full URL path for API calls made to AWS through the boto3 / botocore libraries. The path will be available through span events and transaction traces.
Bug Fixes
Using newrelic-admin to start a GunicornWebWorker with an aiohttp application factory resulted in an application crash.
The agent would fail to start if using the newrelic-admin command to start an aiohttp application factory with GunicornWebWorker. This issue has now been fixed.
Notes
This release of the Python agent adds support for excluding attributes from span events and transaction trace segments, adds a new api called add_custom_parameters, and includes various bug fixes.
The agent can be installed using easy_install/pip/distribute via the Python Package Index or can be downloaded directly from the New Relic download site.
Features
Add ability to exclude attributes from span events and transaction trace segments
This release adds support to exclude attributes (such as
http.url
) from span events (via thespan_events.include
/span_events.exclude
options) and from transaction segments (via thetransaction_segments.include
/transaction_segments.exclude
option).As with other attribute destinations, these new options will inherit values from the top-level
attributes.include
/attributes.exclude
settings. See the documentation for more information.Add public add_custom_parameters API
The method add_custom_parameters on Transaction is now exposed through newrelic.agent.add_custom_parameters
Bug Fixes
Transaction counts were not reported for aiohttp's built-in error pages
When a built-in error route was reached in aiohttp (such as a 404 due to a missing route), transactions were not recorded. As a result, the transaction counts may have been artificially low. aiohttp system route traffic will now be reported.
aiohttp cross application tracing linking to non-Python applications may have been omitted if using multidict<3.0
For aiohttp users using multidict versions less than 3.0, cross application tracing HTTP headers may have been generated in a way that was incompatible with non-Python applications. Headers are now generated in a format compatible with all New Relic agents.
aiohttp 3.5.x versions generated agent instrumentation errors
The agent previously failed to instrument aiohttp applications running versions 3.5.0 and greater. The agent now supports aiohttp versions up to 3.5.1.