@@ -183,6 +183,23 @@ def collect():
183183
184184@_MetricWrapper
185185class Counter (object ):
186+ '''A Counter tracks counts of events or running totals.
187+
188+ Example use cases for Counters:
189+ - Number of requests processed
190+ - Number of items that were inserted into a queue
191+ - Total amount of data that a system has processed
192+
193+ Counters can only go up (and be reset when the process restarts). If your use case can go down,
194+ you should use a Gauge instead.
195+
196+ An example for a Counter:
197+
198+ from prometheus_client import Counter
199+ c = Counter('my_failures_total', 'Description of counter')
200+ c.inc() # Increment by 1
201+ c.inc(1.6) # Increment by given value
202+ '''
186203 _type = 'counter'
187204 _reserved_labelnames = []
188205
@@ -346,6 +363,28 @@ def _samples(self):
346363
347364@_MetricWrapper
348365class Summary (object ):
366+ '''A Summary tracks the size and number of events.
367+
368+ Example use cases for Summaries:
369+ - Response latency
370+ - Request size
371+
372+ Example for a Summary:
373+
374+ from prometheus_client import Summary
375+ s = Summary('request_size_bytes', 'Request size (bytes)')
376+ s.observe(512) # Observe 512 (bytes)
377+
378+ Example for a Summary using time:
379+ from prometheus_client import Summary
380+ REQUEST_TIME = Summary('response_latency_seconds', 'Response latency (seconds)')
381+
382+ @REQUEST_TIME.time()
383+ def create_response(request):
384+ """A dummy function"""
385+ time.sleep(1)
386+
387+ '''
349388 _type = 'summary'
350389 _reserved_labelnames = ['quantile' ]
351390
@@ -404,6 +443,33 @@ def _floatToGoString(d):
404443
405444@_MetricWrapper
406445class Histogram (object ):
446+ '''A Histogram tracks the size and number of events in buckets.
447+
448+ You can use Histograms for aggregatable calculation of quantiles.
449+
450+ Example use cases:
451+ - Response latency
452+ - Request size
453+
454+ Example for a Histogram:
455+
456+ from prometheus_client import Histogram
457+ h = Histogram('request_size_bytes', 'Request size (bytes)')
458+ h.observe(512) # Observe 512 (bytes)
459+
460+
461+ Example for a Histogram using time:
462+ from prometheus_client import Histogram
463+ REQUEST_TIME = Histogram('response_latency_seconds', 'Response latency (seconds)')
464+
465+ @REQUEST_TIME.time()
466+ def create_response(request):
467+ """A dummy function"""
468+ time.sleep(1)
469+
470+ The default buckets are intended to cover a typical web/rpc request from milliseconds to seconds.
471+ They can be overridden by passing `buckets` keyword argument to `Histogram`.
472+ '''
407473 _type = 'histogram'
408474 _reserved_labelnames = ['histogram' ]
409475
0 commit comments