@@ -25,8 +25,8 @@ Counters go up, and reset when the process restarts.
2525``` python
2626from prometheus_client import Counter
2727c = 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
3030```
3131
3232There are utilities to count exceptions raised:
@@ -39,6 +39,7 @@ def f():
3939with c.countExceptions():
4040 pass
4141
42+ # Count only one type of exception
4243with c.countExceptions(ValueError ):
4344 pass
4445```
@@ -51,9 +52,9 @@ Gauges can go up and down.
5152``` python
5253from prometheus_client import Gauge
5354g = 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
5758```
5859
5960There are utilities for common use cases:
@@ -77,18 +78,17 @@ Summaries track the size and number of events.
7778``` python
7879from prometheus_client import Summary
7980s = 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 )
8182```
8283
83- There are utilities for common use cases :
84+ There are utilities for timing code :
8485
8586``` python
86- # Increment when entered, decrement when exited.
87- @g.time ()
87+ @s.time ()
8888def f ():
8989 pass
9090
91- with g .time():
91+ with s .time():
9292 pass
9393```
9494
0 commit comments