Skip to content

Instantly share code, notes, and snippets.

@pglombardo
Last active February 14, 2018 12:27
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 pglombardo/8fcebae3368eb8ea192228b5f8b72e09 to your computer and use it in GitHub Desktop.
Save pglombardo/8fcebae3368eb8ea192228b5f8b72e09 to your computer and use it in GitHub Desktop.
Adding Instana WSGI middleware to a CherryPy application
import cherrypy
import instana
from instana.wsgi import iWSGIMiddleware
# My CherryPy application
class Root(object):
@cherrypy.expose
def index(self):
return "hello world"
cherrypy.config.update({'engine.autoreload.on': False})
cherrypy.server.unsubscribe()
cherrypy.engine.start()
# Wrap the wsgi app in Instana middleware (iWSGIMiddleware)
wsgiapp = iWSGIMiddleware(cherrypy.tree.mount(Root()))
@pglombardo
Copy link
Author

In this example, I used uwsgi as the webserver and booted with:
uwsgi --socket 127.0.0.1:8080 --protocol=http --wsgi-file mycherry.py --callable wsgiapp -H /Users/pglombardo/.local/share/virtualenvs/cherrypyapp-C1BUba0z

^ includes path to my local virtualenv from pipenv

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