MCPcopy Create free account
hub / github.com/prometheus/client_python / collect

Method collect

prometheus_client/gc_collector.py:17–41  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

15 registry.register(self)
16
17 def collect(self) -> Iterable[Metric]:
18 collected = CounterMetricFamily(
19 'python_gc_objects_collected',
20 'Objects collected during gc',
21 labels=['generation'],
22 )
23 uncollectable = CounterMetricFamily(
24 'python_gc_objects_uncollectable',
25 'Uncollectable objects found during GC',
26 labels=['generation'],
27 )
28
29 collections = CounterMetricFamily(
30 'python_gc_collections',
31 'Number of times this generation was collected',
32 labels=['generation'],
33 )
34
35 for gen, stat in enumerate(gc.get_stats()):
36 generation = str(gen)
37 collected.add_metric([generation], value=stat['collected'])
38 uncollectable.add_metric([generation], value=stat['uncollectable'])
39 collections.add_metric([generation], value=stat['collections'])
40
41 return [collected, uncollectable, collections]
42
43
44GC_COLLECTOR = GCCollector()

Callers

nothing calls this directly

Calls 2

add_metricMethod · 0.95
CounterMetricFamilyClass · 0.85

Tested by

no test coverage detected