MCPcopy Index your code
hub / github.com/prometheus/client_python / __init__

Method __init__

prometheus_client/process_collector.py:19–46  ·  view source on GitHub ↗
(self,
                 namespace: str = '',
                 pid: Callable[[], Union[int, str]] = lambda: 'self',
                 proc: str = '/proc',
                 registry: Optional[CollectorRegistry] = REGISTRY)

Source from the content-addressed store, hash-verified

17 """Collector for Standard Exports such as cpu and memory."""
18
19 def __init__(self,
20 namespace: str = '',
21 pid: Callable[[], Union[int, str]] = lambda: 'self',
22 proc: str = '/proc',
23 registry: Optional[CollectorRegistry] = REGISTRY):
24 self._namespace = namespace
25 self._pid = pid
26 self._proc = proc
27 if namespace:
28 self._prefix = namespace + '_process_'
29 else:
30 self._prefix = 'process_'
31 self._ticks = 100.0
32 try:
33 self._ticks = os.sysconf('SC_CLK_TCK')
34 except (ValueError, TypeError, AttributeError, OSError):
35 pass
36
37 self._pagesize = _PAGESIZE
38
39 # This is used to test if we can access /proc.
40 self._btime = 0
41 try:
42 self._btime = self._boot_time()
43 except OSError:
44 pass
45 if registry:
46 registry.register(self)
47
48 def _boot_time(self):
49 with open(os.path.join(self._proc, 'stat'), 'rb') as stat:

Callers

nothing calls this directly

Calls 2

_boot_timeMethod · 0.95
registerMethod · 0.45

Tested by

no test coverage detected