Commits

Donald Stufft committed 62cc30e

add new relic

  • Participants
  • Parent commits b77b82f

Comments (0)

Files changed (1)

 import re
 from functools import partial
 
+try:
+    import newrelic
+except ImportError:
+    newrelic = None
+else:
+    newrelic.agent.initialize('/data/pypi/newrelic.ini')
+
 store.keep_conn = True
 
 CONFIG_FILE = os.environ.get("PYPI_CONFIG", os.path.join(prefix, 'config.ini'))
 # Handle Caching at the WSGI layer
 application = CacheControlMiddleware(application)
 
+# If we have New Relic, wrap the application
+if newrelic:
+    application = newrelic.agent.WSGIApplicationWrapper(application)
+
 
 # pretend to be like the UWSGI configuration - set SCRIPT_NAME to the first
 # part of the PATH_INFO if it's valid and remove that part from the PATH_INFO