Skip to content

Commit

Permalink
[MIG] newrelic: Migration to 16.0
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanRijnhart committed Dec 11, 2023
1 parent 1dde48d commit ccc8b07
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
17 changes: 8 additions & 9 deletions newrelic/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@ def initialization():
target.app = nr_app

# Workers new WSGI Application
target = odoo.service.wsgi_server
target.application_unproxied = newrelic.agent.WSGIApplicationWrapper(target.application_unproxied)

odoo.http.Application = newrelic.agent.WSGIApplicationWrapper(odoo.http.Application)

try:
_logger.info('attaching to bus controller')
import odoo.addons.bus.controllers.main
newrelic.agent.wrap_background_task(odoo.addons.bus.controllers.main, 'BusController._poll', application=nr_app)
newrelic.agent.wrap_background_task(odoo.addons.bus.websocket, 'Websocket._dispatch_bus_notifications', application=nr_app)
_logger.info('finished attaching to bus controller')
except Exception as e:
_logger.exception(e)
Expand Down Expand Up @@ -105,8 +104,8 @@ def status_code(exc, value, tb):
if isinstance(value, HTTPException):
return value.code

def _nr_wrapper_handle_exception_(wrapped):
def _handle_exception(*args, **kwargs):
def _nr_wrapper_handle_error(wrapped):
def handle_error(*args, **kwargs):
transaction = newrelic.agent.current_transaction()

if transaction is None:
Expand All @@ -118,10 +117,10 @@ def _handle_exception(*args, **kwargs):
with newrelic.agent.FunctionTrace(transaction, name):
return wrapped(*args, **kwargs)

return _handle_exception
return handle_error

target = odoo.http.WebRequest
target._handle_exception = _nr_wrapper_handle_exception_(target._handle_exception)
for target in (odoo.http.HttpDispatcher, odoo.http.JsonRPCDispatcher):
target.handle_error = _nr_wrapper_handle_error(target.handle_error)


try:
Expand Down
2 changes: 1 addition & 1 deletion newrelic/__manifest__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
'name': 'NewRelic Instrumentation',
'description': 'Wraps requests etc.',
'version': '15.0.0.9.0',
'version': '16.0.0.9.0',
'website': 'https://hibou.io/',
'author': 'Hibou Corp. <hello@hibou.io>',
'license': 'AGPL-3',
Expand Down

0 comments on commit ccc8b07

Please sign in to comment.