Python agent instrumentation help

I need help with instrumenting APM for the application based on odoo python app.

I am able to validate newrelic configuration using validate-config command however when I configure python-agent with application, data is not showing up in the APM console.

Below are the steps that I followed:

  1. pip3 install newrelic
  2. newrelic-admin generate-config /etc/newrelic.ini
  3. export NEW_RELIC_CONFIG_FILE=/etc/newrelic.ini
  4. Add below line in /opt/odoo/odoo-server/odoo-bin
    import newrelic.agent
    newrelic.agent.initialize(’/etc/newrelic.ini’)
  5. restart the application

No error logs observed in newrelic debug logs.
Server details:
Ubuntu 18.04.3 LTS and Nginx

Welcome to the community @nikhil.chaudhari1 - thanks for posting your first question.

I think the best next step for troubleshooting your installation will be to run our NR Diagnostic tool, which can point out a number issues. There are instructions for NR Diag and some other troubleshooting tips here:

Let us know if these steps fail and we’ll be here to work with you!

1 Like

Hello @hrosss thanks for reply.

I have tried the provided steps below are my comments for each point.

  1. Confirm the app is receiving traffic, has been for at least 5 min, and continues to receive traffic during troubleshooting.
    Site is active

  2. Run NrDiag to collect data then validate the followin (NrDiag fails due to complete as it detects pip. pip3 is configured on the server and newrelic package is listed)

2.1 Confirm Python version and OS is supported.
Python Version: Python 3.6.9
OS: Ubuntu 18.04.3 LTS

2.2 Confirm the newrelic package is visible on the pip freezelist executed from within the virtualenv.
Application is not running in virtualenv. newrelic package present
pip3 list | grep newrelic
newrelic (5.20.0.149)

2.3 Make sure the application is started using the same virtualenv in which newrelic package was installed.
Application is not running in virtualenv.

2.4 Confirm license_key & app_name is set within the newrelic.ini file OR with use of environment variables.
set within the newrelic.ini

2.5Confirm the newrelic-admin script is being used to start up the application.
Run the Python Agent Test 5.
Python agnet test sucessfull

2.6Check for High Security Mode configuration mismatches.
If newrelic-admin can’t be used or simply doesn’t yield expected results, we recommend an advanced integration method within the applications code.
2.7 Confirm it’s a web application and if not, we recommend a solution for monitoring background scripts or jobs 1.
It is a web application

2.8 Check the log file is generated after configuring logging in the agent 1.
Debug log file shows error
22720/NR-Activate-Session/odo ostage) newrelic.core.application ERROR - Unexpected exception when registering agent with the data collector. If this problem persists, please report this problem to New Relic support for further investigation.
Traceback (most recent call last):
File “/usr/local/lib/python3.6/dist-packages/newrelic/core/application.py”, line 347, in connect_to_data_collector
self.linked_applications, environment_settings())
File “/usr/local/lib/python3.6/dist-packages/newrelic/core/data_collector.py”, line 236, in create_session
return Session(app_name, linked_applications, environment, settings)
File “/usr/local/lib/python3.6/dist-packages/newrelic/core/data_collector.py”, line 41, in init
app_name, linked_applications, environment, settings, client_cls=self.CLIENT
File “/usr/local/lib/python3.6/dist-packages/newrelic/core/agent_protocol.py”, line 435, in connect
redirect_host = preconnect.send(“preconnect”)[“redirect_host”]
File “/usr/local/lib/python3.6/dist-packages/newrelic/core/agent_protocol.py”, line 209, in send
params=params, headers=headers, payload=payload
File “/usr/local/lib/python3.6/dist-packages/newrelic/common/agent_http.py”, line 439, in send_request
**self._urlopen_kwargs
File “/usr/local/lib/python3.6/dist-packages/newrelic/packages/urllib3/request.py”, line 97, in request_encode_url
return self.urlopen(method, url, **extra_kw)
File “/usr/local/lib/python3.6/dist-packages/newrelic/packages/urllib3/connectionpool.py”, line 677, in urlopen
chunked=chunked,
File “/usr/local/lib/python3.6/dist-packages/newrelic/packages/urllib3/connectionpool.py”, line 381, in _make_request
self._validate_conn(conn)
File “/usr/local/lib/python3.6/dist-packages/newrelic/packages/urllib3/connectionpool.py”, line 978, in validate_conn
conn.connect()
File “/usr/local/lib/python3.6/dist-packages/newrelic/packages/urllib3/connection.py”, line 345, in connect
cert_reqs=resolve_cert_reqs(self.cert_reqs),
File "/usr/local/lib/python3.6/dist-packages/newrelic/packages/urllib3/util/ssl
.py", line 277, in create_urllib3_context
context.options |= options
File “/usr/lib/python3.6/ssl.py”, line 465, in options
super(SSLContext, SSLContext).options.set(self, value)
File “/usr/lib/python3.6/ssl.py”, line 465, in options
super(SSLContext, SSLContext).options.set(self, value)
File “/usr/lib/python3.6/ssl.py”, line 465, in options
super(SSLContext, SSLContext).options.set(self, value)
[Previous line repeated 291 more times]
RecursionError: maximum recursion depth exceeded

Hi @nikhil.chaudhari1,

It looks like you’re using this framework, correct?

This error seems to be unrelated to the agent, and more so on gevent:

I would highly recommend reviewing this issue and making the suggested workaround in the Github example above.

1 Like