Skip to content

Commit ad3d4e6

Browse files
committed
Clean up aiohttp instrumentation
1 parent bda0c5a commit ad3d4e6

File tree

1 file changed

+6
-20
lines changed

1 file changed

+6
-20
lines changed

newrelic/hooks/framework_aiohttp.py

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717

1818
from newrelic.api.external_trace import ExternalTrace
1919
from newrelic.api.function_trace import function_trace
20-
from newrelic.api.time_trace import notice_error
2120
from newrelic.api.transaction import current_transaction, ignore_transaction
2221
from newrelic.api.web_transaction import web_transaction
2322
from 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
7063
def _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

357345
def 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

367354
def instrument_aiohttp_web_response(module):
368355
wrap_function_wrapper(module, "Response.prepare", _nr_aiohttp_response_prepare_)
369-

0 commit comments

Comments
 (0)