Skip to content

Commit a76bf82

Browse files
authored
New document explaining how to use the WSGI wrapper
1 parent a98e106 commit a76bf82

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

WSGI.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
The Instana sensor includes WSGI middleware that can be added to any WSGI compliant stack. This is automated for various stacks but can also be done manually for those we haven't added support for yet.
2+
3+
The general usage is:
4+
5+
```python
6+
import instana
7+
from instana.wsgi import iWSGIMiddleware
8+
9+
# Wrap the wsgi app in Instana middleware (iWSGIMiddleware)
10+
wsgiapp = iWSGIMiddleware(MyWSGIApplication())
11+
```
12+
13+
We are working to automate this for all major frameworks but in the meantime, here are some specific quick starts for those we don't have automatic support for yet.
14+
15+
## CherryPy
16+
17+
```python
18+
import cherrypy
19+
import instana
20+
from instana.wsgi import iWSGIMiddleware
21+
22+
# My CherryPy application
23+
class Root(object):
24+
@cherrypy.expose
25+
def index(self):
26+
return "hello world"
27+
28+
cherrypy.config.update({'engine.autoreload.on': False})
29+
cherrypy.server.unsubscribe()
30+
cherrypy.engine.start()
31+
32+
# Wrap the wsgi app in Instana middleware (iWSGIMiddleware)
33+
wsgiapp = iWSGIMiddleware(cherrypy.tree.mount(Root()))
34+
```
35+
36+
In this example, we use uwsgi as the webserver and booted with:
37+
38+
`uwsgi --socket 127.0.0.1:8080 --protocol=http --wsgi-file mycherry.py --callable wsgiapp -H ~/.local/share/virtualenvs/cherrypyapp-C1BUba0z`
39+
40+
Where `~/.local/share/virtualenvs/cherrypyapp-C1BUba0z` is the path to my local virtualenv from pipenv

0 commit comments

Comments
 (0)