Help With Python, uWSGI and New Relic
However, I am struggling to setup New Relic's uWSGI integration using their documentation (
Has anyone else use New Relic with uWSGI and can point me in the right direction?
2 Replies
from django.core.wsgi import get_wsgi_application
newrelic_ini = 'path/to/newrelic.ini'
try:
import newrelic.agent
except:
application = get_wsgi_application()
else:
newrelic.agent.initialize(newrelic_ini, 'production')
@newrelic.agent.wsgi_application()
def application(environ, start_response):
_application = get_wsgi_application()
return _application(environ, start_response)
I do the try/except thing so that I can use the same wsgi.py on dev machines without New Relic.
I'm using Bottlepy as my web app framework, so I just needed to do the following:
newrelic_ini = '/newrelic.ini'
try:
import newrelic.agent
newrelic.agent.initialize(newrelic_ini, 'production')
application = newrelic.agent.WSGIApplicationWrapper(bottle.default_app())
except:
print 'newrelic agent not found... continuing anyways'
application = bottle.default_app()
Note: I had to follow the instructions here (
Replaced
<app mountpoint="/"></app>
with
<module>wsgi_configuration_module</module>