(self,
namespace: str = '',
pid: Callable[[], Union[int, str]] = lambda: 'self',
proc: str = '/proc',
registry: Optional[CollectorRegistry] = REGISTRY)
| 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: |
nothing calls this directly
no test coverage detected