Last active
February 14, 2018 12:27
-
-
Save pglombardo/8fcebae3368eb8ea192228b5f8b72e09 to your computer and use it in GitHub Desktop.
Adding Instana WSGI middleware to a CherryPy application
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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