docstr: PrometheusClient is BentoML's own prometheus client that extends the official Python client.
  
  It sets up a multiprocess dir for Prometheus to work in multiprocess mode, which is required
  for BentoML to work in production.
  
  .. note::
  
     For Prometheus to behave properly, ``prometheus_client`` must be imported after this client
     is called. This has to do with ``prometheus_client`` relies on ``PROMEHEUS_MULTIPROC_DIR``, which
     will be set by this client.
  
  For API documentation, refer to https://docs.bentoml.com/en/latest/reference/metrics.html.
docstr_tok: ["PrometheusClient","is","BentoML","'s","own","prometheus","client","that","extends","the","official","Python","client",".","It","sets","up","a","multiprocess","dir","for","Prometheus","to","work","in","multiprocess","mode",",","which","is","required","for","BentoML","to","work","in","production",".","..","note",":",":","For","Prometheus","to","behave","properly",",","``","prometheus_client","``","must","be","imported","after","this","client","is","called",".","This","has","to","do","with","``","prometheus_client","``","relies","on","``","PROMEHEUS_MULTIPROC_DIR","``",",","which","will","be","set","by","this","client",".","For","API","documentation",",","refer","to","https",":","\/\/docs.bentoml.com\/en\/latest\/reference\/metrics.html","."]
code: def __init__(
      self,
      *,
      multiproc: bool = True,
      multiproc_dir: str | None = None,
  ):
      """
      PrometheusClient is BentoML's own prometheus client that extends the official Python client.
  
      It sets up a multiprocess dir for Prometheus to work in multiprocess mode, which is required
      for BentoML to work in production.
  
      .. note::
  
         For Prometheus to behave properly, ``prometheus_client`` must be imported after this client
         is called. This has to do with ``prometheus_client`` relies on ``PROMEHEUS_MULTIPROC_DIR``, which
         will be set by this client.
  
      For API documentation, refer to https://docs.bentoml.com/en/latest/reference/metrics.html.
      """
      if multiproc:
          assert (
              multiproc_dir is not None
          ), "multiproc_dir must be provided"
  
      self.multiproc = multiproc
      self.multiproc_dir: str | None = multiproc_dir
      self._registry = None
      self._imported = False
      self._pid: int | None = None
  
imports: from __future__ import annotations
  import logging
  import os
  import sys
  import typing
  from functools import partial
  from typing import TYPE_CHECKING
label_desc: Use image node_id 1 to create a new PrometheusClient object  with example: obj = PrometheusClient()