-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathREADME
99 lines (64 loc) · 1.93 KB
/
README
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
README
======
A python library to send application metrics using UDP.
Installation
------------
.. code-block:: bash
pip install measures
Usage
-----
* count
.. code-block:: python
from measures import Measure
measure = Measure('myclient', ('localhost', 1984))
measure.count('mymetric', dimensions={'name': 'john'})
* time (measure time spent on a given block)
.. code-block:: python
import time
from measures import Measure
measure = Measure('myclient', ('localhost', 1984))
with measure.time('mymetric'):
# do some slow operation:
time.sleep(3.14159)
.. code-block:: python
import time
from measures import Measure
measure = Measure('myclient', ('localhost', 1984))
with measure.time('mymetric') as dimensions:
# do some slow operation:
time.sleep(1.61803)
# add any relevant information, if necessary:
dimensions['relevant_info'] = 'pertinent_info'
* send
.. code-block:: python
from measures import Measure
measure = Measure('myclient', ('localhost', 1984))
dimensions = {
'time': 10.1,
'relevant_info': pertinent_info
}
measure.send('mymetric', dimensions)
* multiple destinations
Metrics can be sent to more than one backend
.. code-block:: python
from measures import Measure
measure = Measure('myclient', [('backend.host.1', 1984), ('backend.host.2', 1984)]
Contributing
------------
* Set up your environment
.. code-block:: bash
git clone https://github.com/globocom/measures.git
cd measures
mkvirtualenv measures
pip install -r test_requirements.txt
* Run the tests
.. code-block:: bash
make tests
* Write tests for your new feature or bug fix
* Write needed code changes
* Iterate, have fun :)
* Make a pull request with your changes
Who do I talk to?
-----------------
* File an issue at https://github.com/globocom/measures or contact us at