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.
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:
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.
class MainHandler(tornado.web.RequestHandler): @tornado.gen.coroutine def get(self): yield gen.sleep(0.2)
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.
transaction = newrelic.agent.current_transaction() with newrelic.agent.FunctionTrace(transaction, "my_trace"): pass
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.