Skip to content

Commit

Permalink
[IMP] newrelic: wrap target server initialization and skip in case od…
Browse files Browse the repository at this point in the history
…oo stop_after_init
  • Loading branch information
Shamsidinkhon committed Jun 12, 2023
1 parent e77d9a4 commit 1dde48d
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions newrelic/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import os
from . import controllers
from odoo.tools import config

import logging
_logger = logging.getLogger(__name__)

try:

def initialization():
import odoo
target = odoo.service.server.server
if not target:
Expand All @@ -19,7 +21,6 @@
if instrumented:
_logger.info("NewRelic instrumented already")
else:
import odoo.tools.config as config
import newrelic.agent


Expand Down Expand Up @@ -122,5 +123,11 @@ def _handle_exception(*args, **kwargs):
target = odoo.http.WebRequest
target._handle_exception = _nr_wrapper_handle_exception_(target._handle_exception)


try:
# the Odoo server will stop after its initialization, server will not be available for monkey-patching
if not config.get("stop_after_init"):
initialization()

except ImportError:
_logger.warn('newrelic python module not installed or other missing module')

0 comments on commit 1dde48d

Please sign in to comment.