1717
1818from newrelic .api .external_trace import ExternalTrace
1919from newrelic .api .function_trace import function_trace
20- from newrelic .api .time_trace import notice_error
2120from newrelic .api .transaction import current_transaction , ignore_transaction
2221from newrelic .api .web_transaction import web_transaction
2322from newrelic .common .async_wrapper import async_wrapper , is_coroutine_callable
@@ -60,12 +59,6 @@ def _is_expected(exc, value, tb):
6059 return _is_expected
6160
6261
63- def _nr_process_response (response , transaction ):
64- nr_headers = transaction .process_response (response .status , response .headers )
65-
66- response ._headers .update (nr_headers )
67-
68-
6962@function_wrapper
7063def _nr_aiohttp_view_wrapper_ (wrapped , instance , args , kwargs ):
7164 transaction = current_transaction ()
@@ -259,19 +252,14 @@ def _nr_aiohttp_request_wrapper_(wrapped, instance, args, kwargs):
259252 trace = ExternalTrace ("aiohttp" , str (url ), method )
260253
261254 async def _coro ():
262- try :
263- response = await wrapped (* args , ** kwargs )
264-
265- try :
266- trace .process_response (status_code = response .status )
267- except :
268- pass
255+ response = await wrapped (* args , ** kwargs )
269256
270- return response
271- except Exception :
272- notice_error ()
257+ try :
258+ trace .process_response_headers (response .headers .items ())
259+ except :
260+ pass
273261
274- raise
262+ return response
275263
276264 return async_wrapper (wrapped )(_coro , trace )()
277265
@@ -355,7 +343,6 @@ async def _coro(*_args, **_kwargs):
355343
356344
357345def instrument_aiohttp_web (module ):
358- global _nr_process_response
359346 wrap_function_wrapper (module , "Application._handle" , _nr_request_wrapper )
360347 wrap_function_wrapper (module , "Application.__init__" , _nr_aiohttp_wrap_application_init_ )
361348
@@ -366,4 +353,3 @@ def instrument_aiohttp_wsgi(module):
366353
367354def instrument_aiohttp_web_response (module ):
368355 wrap_function_wrapper (module , "Response.prepare" , _nr_aiohttp_response_prepare_ )
369-
0 commit comments