Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IMP] newrelic: wrap target server initialization #16

Open
wants to merge 1 commit into
base: 15.0
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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')