|
6 | 6 |
|
7 | 7 | The instana package provides Python metrics and traces (request, queue & cross-host) for [Instana](https://www.instana.com/). |
8 | 8 |
|
9 | | -[](https://travis-ci.org/instana/python-sensor) |
10 | | -[](http://opentracing.io) |
11 | | - |
12 | | -## Note |
13 | | - |
14 | 9 | This package supports Python 2.7 or greater. |
15 | 10 |
|
16 | 11 | Any and all feedback is welcome. Happy Python visibility. |
17 | 12 |
|
18 | | -## Installation |
19 | | - |
20 | | -`pip install instana` into the virtual-env or container ([hosted on pypi](https://pypi.python.org/pypi/instana)) |
21 | | - |
22 | | -## Django |
23 | | - |
24 | | -For Django versions >= 1.10 set the following environment variable in your _application boot environment_ and then restart your application: |
25 | | - |
26 | | - `export AUTOWRAPT_BOOTSTRAP=django` |
27 | | - |
28 | | -For Django version 1.9.x, instead set: |
29 | | - |
30 | | - `export AUTOWRAPT_BOOTSTRAP=django19` |
31 | | - |
32 | | -## Flask |
33 | | - |
34 | | -To enable the Flask instrumentation, set the following environment variable in your _application boot environment_ and then restart your application: |
35 | | - |
36 | | - `export AUTOWRAPT_BOOTSTRAP=flask` |
37 | | - |
38 | | -## WSGI Compliant Stacks |
39 | | - |
40 | | -The Instana sensor bundles with it WSGI middleware. The usage of this middleware is automated for various frameworks but for those that arent' supported yet, see the [WSGI documentation](WSGI.md) for details on how to manually add it to your stack. |
41 | | - |
42 | | -## Runtime Monitoring Only |
43 | | - |
44 | | -_Note: When the Django or Flask instrumentation is used, runtime monitoring is automatically included. Use this section if you only want to see runtime metrics._ |
45 | | - |
46 | | -To enable runtime monitoring (without request tracing), set the following environment variable in your _application boot environment_ and then restart your application: |
47 | | - |
48 | | - `export AUTOWRAPT_BOOTSTRAP=runtime` |
49 | | - |
50 | | -## uWSGI |
51 | | - |
52 | | -### Threads |
53 | | - |
54 | | -This Python instrumentation spawns a lightweight background thread to periodically collect and report process metrics. By default, the GIL and threading is disabled under uWSGI. If you wish to instrument your application running under uWSGI, make sure that you enable threads by passing `--enable-threads` (or `enable-threads = true` in ini style). More details in the [uWSGI documentation](https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#a-note-on-python-threads). |
55 | | - |
56 | | -### Forking off Workers |
57 | | - |
58 | | -If you use uWSGI in forking workers mode, you must specify `--lazy-apps` (or `lazy-apps = true` in ini style) to load the application in the worker instead of the master process. |
59 | | - |
60 | | -### uWSGI Example: Command-line |
61 | | - |
62 | | -```sh |
63 | | -uwsgi --socket 0.0.0.0:5000 --protocol=http -w wsgi -p 4 --enable-threads --lazy-apps |
64 | | -``` |
65 | | - |
66 | | -### uWSGI Example: ini file |
67 | | - |
68 | | -```ini |
69 | | -[uwsgi] |
70 | | -http = :5000 |
71 | | -master = true |
72 | | -processes = 4 |
73 | | -enable-threads = true # required |
74 | | -lazy-apps = true # if using "processes", set lazy-apps to true |
75 | | - |
76 | | -# Set the Instana sensor environment variable here |
77 | | -env = AUTOWRAPT_BOOTSTRAP=flask |
78 | | -``` |
| 13 | +[](https://travis-ci.org/instana/python-sensor) |
| 14 | +[](http://opentracing.io) |
79 | 15 |
|
80 | | -## Usage |
| 16 | +## Usage & Installation |
81 | 17 |
|
82 | 18 | The instana package will automatically collect key metrics from your Python processes. Just install and go. |
83 | 19 |
|
84 | | -## Want End User Monitoring? |
85 | | - |
86 | | -Instana provides deep end user monitoring that links server side traces with browser events to give you a complete view from server to browser. |
87 | | - |
88 | | -For Python templates and views, get your EUM API key from your Instana dashboard and you can call `instana.helpers.eum_snippet(api_key='abc')` from within your layout file. This will output |
89 | | -a small javascript snippet of code to instrument browser events. It's based on [Weasel](https://github.com/instana/weasel). Check it out. |
90 | | - |
91 | | -As an example, you could do the following: |
92 | | - |
93 | | -```python |
94 | | -from instana.helpers import eum_snippet |
95 | | - |
96 | | -instana.api_key = 'abc' |
97 | | -meta_kvs = { 'username': user.name } |
98 | | - |
99 | | -# This will return a string containing the EUM javascript for the layout or view. |
100 | | -eum_snippet(meta=meta_kvs) |
101 | | -``` |
102 | | - |
103 | | -The optional second argument to `eum_snippet()` is a hash of metadata key/values that will be reported along with the browser instrumentation. |
104 | | - |
105 | | - |
| 20 | +`pip install instana` into the virtual-env or container ([hosted on pypi](https://pypi.python.org/pypi/instana)) |
106 | 21 |
|
107 | | -See also the [End User Monitoring](https://docs.instana.io/products/website_monitoring/#configuration) in the Instana documentation portal. |
| 22 | +See our detailed [Installation document](INSTALLATION.md) for environment specific information covering Django, Flask, End-user Monitoring (EUM) and more. |
108 | 23 |
|
109 | 24 | ## OpenTracing |
110 | 25 |
|
|
0 commit comments