Hi,
I'm trying to configure an app monitoring agent on a Pylons app, so the recommended setup is to initialize the agent before all modules import, and also create a middleware class to collect stats on each request. I have the following setup working but there's the potential risk for the monitoring agent being initialized twice and the agent not working as intended. Any pointers on how to take a better approach?.
import newrelic.agent
#class in config/middleware.py
class NewRelicAgent(object):
def __init__(self, app):
newrelic.agent.initialize('/path/to/file/newrelic.ini')
@newrelic.agent.wsgi_application()
def __call__(self, environ, start_response):
return
self.app(environ, start_response)
#config/middleware.py make_app def
app = NewRelicAgent(app)