@@ -25,8 +25,8 @@ Counters go up, and reset when the process restarts.
25
25
``` python
26
26
from prometheus_client import Counter
27
27
c = Counter(' my_failures_total' , ' Description of counter' )
28
- c.inc() # Increment by 1
29
- c.inc(10 ) # Increment by given value
28
+ c.inc() # Increment by 1
29
+ c.inc(1.6 ) # Increment by given value
30
30
```
31
31
32
32
There are utilities to count exceptions raised:
@@ -39,6 +39,7 @@ def f():
39
39
with c.countExceptions():
40
40
pass
41
41
42
+ # Count only one type of exception
42
43
with c.countExceptions(ValueError ):
43
44
pass
44
45
```
@@ -51,9 +52,9 @@ Gauges can go up and down.
51
52
``` python
52
53
from prometheus_client import Gauge
53
54
g = Gauge(' my_inprogress_requests' , ' Description of gauge' )
54
- g.inc() # Increment by 1
55
- g.dev(10 ) # Decrement by given value
56
- g.set(7 ) # Set to a given value
55
+ g.inc() # Increment by 1
56
+ g.dev(10 ) # Decrement by given value
57
+ g.set(4.2 ) # Set to a given value
57
58
```
58
59
59
60
There are utilities for common use cases:
@@ -77,18 +78,17 @@ Summaries track the size and number of events.
77
78
``` python
78
79
from prometheus_client import Summary
79
80
s = Summary(' request_latency_seconds' , ' Description of summary' )
80
- s.observe(5 ) # Observe 5 (seconds)
81
+ s.observe(4.7 ) # Observe 4.7 (seconds in this case )
81
82
```
82
83
83
- There are utilities for common use cases :
84
+ There are utilities for timing code :
84
85
85
86
``` python
86
- # Increment when entered, decrement when exited.
87
- @g.time ()
87
+ @s.time ()
88
88
def f ():
89
89
pass
90
90
91
- with g .time():
91
+ with s .time():
92
92
pass
93
93
```
94
94
0 commit comments