File: README.rst

package info (click to toggle)
python-eventlet 0.40.1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 3,200 kB
  • sloc: python: 25,101; sh: 78; makefile: 31
file content (130 lines) | stat: -rw-r--r-- 3,866 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
eventlet.zipkin
===============

`Zipkin <http://twitter.github.io/zipkin/>`_ is a distributed tracing system developed at Twitter.
This package provides a WSGI application using eventlet
with tracing facility that complies with Zipkin.

Why use it?
From the http://twitter.github.io/zipkin/:

"Collecting traces helps developers gain deeper knowledge about how
certain requests perform in a distributed system. Let's say we're having
problems with user requests timing out. We can look up traced requests
that timed out and display it in the web UI. We'll be able to quickly
find the service responsible for adding the unexpected response time. If
the service has been annotated adequately we can also find out where in
that service the issue is happening."


Screenshot
----------

Zipkin web ui screenshots obtained when applying this module to
`OpenStack swift <https://github.com/openstack/swift>`_  are in example/.


Requirement
-----------

A eventlet.zipkin needs `python scribe client <https://pypi.python.org/pypi/facebook-scribe/>`_
and `thrift <https://thrift.apache.org/>`_ (>=0.9),
because the zipkin collector speaks `scribe <https://github.com/facebookarchive/scribe>`_ protocol.
Below command will install both scribe client and thrift.

Install facebook-scribe:

::

    pip install facebook-scribe

**Python**: ``2.7`` (Because the current Python Thrift release doesn't support Python 3)


How to use
----------

Add tracing facility to your application
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Apply the monkey patch before you start wsgi server.

.. code:: python

    # Add only 2 lines to your code
    from eventlet.zipkin import patcher
    patcher.enable_trace_patch()

    # existing code
    from eventlet import wsgi
    wsgi.server(sock, app)

You can pass some parameters to ``enable_trace_patch()``

* host: Scribe daemon IP address (default: '127.0.0.1')
* port: Scribe daemon port (default: 9410)
* trace_app_log: A Boolean indicating if the tracer will trace application log together or not. This facility assume that your application uses python standard logging library. (default: False)
* sampling_rate: A Float value (0.0~1.0) that indicates the tracing frequency. If you specify 1.0, all requests are traced and sent to Zipkin collecotr. If you specify 0.1, only 1/10 requests are traced. (defult: 1.0)


(Option) Annotation API
~~~~~~~~~~~~~~~~~~~~~~~
If you want to record additional information,
you can use below API from anywhere in your code.

.. code:: python

   from eventlet.zipkin import api

   api.put_annotation('Cache miss for %s' % request)
   api.put_key_value('key', 'value')




Zipkin simple setup
-------------------

::

    $ git clone https://github.com/twitter/zipkin.git
    $ cd zipkin
    # Open 3 terminals
    (terminal1) $ bin/collector
    (terminal2) $ bin/query
    (terminal3) $ bin/web

Access http://localhost:8080 from your browser.


(Option) fluentd
----------------
If you want to buffer the tracing data for performance,
`fluentd scribe plugin <http://docs.fluentd.org/articles/in_scribe>`_ is available.
Since ``out_scribe plugin`` extends `Buffer Plugin <http://docs.fluentd.org/articles/buffer-plugin-overview>`_ ,
you can customize buffering parameters in the manner of fluentd.
Scribe plugin is included in td-agent by default.


Sample: ``/etc/td-agent/td-agent.conf``

::

   # in_scribe
   <source>
     type scribe
     port 9999
   </source>

   # out_scribe
   <match zipkin.**>
     type scribe
     host Zipkin_collector_IP
     port 9410
     flush_interval 60s
     buffer_chunk_limit 256m
   </match>

| And, you need to specify ``patcher.enable_trace_patch(port=9999)`` for in_scribe.
| In this case, trace data is passed like below.
| Your application => Local fluentd in_scribe (9999) => Local fluentd out_scribe <buffering> =====> Remote zipkin collector (9410)