Skip to content

Instantly share code, notes, and snippets.

@miohtama
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miohtama/eff2ad079ba231ec4c3a to your computer and use it in GitHub Desktop.
Save miohtama/eff2ad079ba231ec4c3a to your computer and use it in GitHub Desktop.
Newrelic + Pyramid + uWSGI
def wrap_wsgi_app(self, app):
"""Perform any necessary WSGI application wrapping.
Wrap WSGI application to another WSGI application e.g. for the monitoring support. By default support New Relic.
"""
if "NEW_RELIC_CONFIG_FILE" in os.environ:
# Wrap for New Relic
# libgcc_s.so.1 must be installed for pthread_cancel to work
import newrelic.agent
return newrelic.agent.wsgi_application()(app)
return app
def make_wsgi_app(self, sanity_check=True):
"""Create WSGI application from the current setup.
:param sanity_check: True if perform post-initialization sanity checks.
:return: WSGI application
"""
# Let pyramid Configurator create initial app
app = self.config.make_wsgi_app()
# Carry the initializer around so we can access it in tests
app.initializer = self
app = self.wrap_wsgi_app(app)
return app
# the below is required by new relic. be sure to monitor your system
# memory since we're enabling threads
# https://newrelic.com/docs/python/python-agent-and-uwsgi
# http://uwsgi-docs.readthedocs.org/en/latest/Options.html
enable-threads = true
single-interpreter = true
lazy-apps = true
@miohtama
Copy link
Author

limit-as it not compatible with New Relic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment