class_docstr: A monitor process for monitoring Ray nodes.
  
  Attributes:
      dashboard_agent: The DashboardAgent object contains global config
class_docstr_tok: ["A","monitor","process","for","monitoring","Ray","nodes",".","Attributes",":","dashboard_agent",":","The","DashboardAgent","object","contains","global","config"]
docstr: Initialize the reporter object.
docstr_tok: ["Initialize","the","reporter","object","."]
code: def __init__(self, dashboard_agent):
      """Initialize the reporter object."""
      super().__init__(dashboard_agent)
  
      if IN_KUBERNETES_POD or IN_CONTAINER:
          # psutil does not give a meaningful logical cpu count when in a K8s pod, or
          # in a container in general.
          # Use ray._private.utils for this instead.
          logical_cpu_count = ray._private.utils.get_num_cpus(
              override_docker_cpu_warning=True
          )
          # (Override the docker warning to avoid dashboard log spam.)
  
          # The dashboard expects a physical CPU count as well.
          # This is not always meaningful in a container, but we will go ahead
          # and give the dashboard what it wants using psutil.
          physical_cpu_count = psutil.cpu_count(logical=False)
      else:
          logical_cpu_count = psutil.cpu_count()
          physical_cpu_count = psutil.cpu_count(logical=False)
      self._cpu_counts = (logical_cpu_count, physical_cpu_count)
      self._gcs_aio_client = dashboard_agent.gcs_aio_client
      self._ip = dashboard_agent.ip
      self._log_dir = dashboard_agent.log_dir
      self._is_head_node = (
          self._ip == dashboard_agent.gcs_address.split(":")[0]
      )
      self._hostname = socket.gethostname()
      # (pid, created_time) -> psutil.Process
      self._workers = {}
      # psutil.Process of the parent.
      self._raylet_proc = None
      # psutil.Process of the current process.
      self._agent_proc = None
      # The last reported worker proc names (e.g., ray::*).
      self._latest_worker_proc_names = set()
      self._network_stats_hist = [(0, (0.0, 0.0))]  # time, (sent, recv)
      self._disk_io_stats_hist = [
          (0, (0.0, 0.0, 0, 0))
      ]  # time, (bytes read, bytes written, read ops, write ops)
      self._metrics_collection_disabled = (
          dashboard_agent.metrics_collection_disabled
      )
      self._metrics_agent = None
      self._session_name = dashboard_agent.session_name
      if not self._metrics_collection_disabled:
          try:
              stats_exporter = prometheus_exporter.new_stats_exporter(
                  prometheus_exporter.Options(
                      namespace="ray",
                      port=dashboard_agent.metrics_export_port,
                      address="127.0.0.1"
                      if self._ip == "127.0.0.1"
                      else "",
                  )
              )
          except Exception:
              # TODO(SongGuyang): Catch the exception here because there is
              # port conflict issue which brought from static port. We should
              # remove this after we find better port resolution.
              logger.exception(
                  "Failed to start prometheus stats exporter. Agent will stay "
                  "alive but disable the stats."
              )
              stats_exporter = None
  
          self._metrics_agent = MetricsAgent(
              stats_module.stats.view_manager,
              stats_module.stats.stats_recorder,
              stats_exporter,
          )
          if self._metrics_agent.proxy_exporter_collector:
              # proxy_exporter_collector is None
              # if Prometheus server is not started.
              REGISTRY.register(
                  self._metrics_agent.proxy_exporter_collector
              )
      self._key = (
          f"{reporter_consts.REPORTER_PREFIX}"
          f"{self._dashboard_agent.node_id}"
      )
  
imports: import asyncio
  import datetime
  import json
  import logging
  import os
  import socket
  import sys
  import traceback
  import psutil
  from typing import List, Optional, Tuple, TypedDict, Union
  from collections import defaultdict
  import ray
  import ray._private.services
  import ray._private.utils
  from ray.dashboard.consts import GCS_RPC_TIMEOUT_SECONDS, COMPONENT_METRICS_TAG_KEYS
  from ray.dashboard.modules.reporter.profile_manager import CpuProfilingManager, MemoryProfilingManager
  import ray.dashboard.modules.reporter.reporter_consts
  import ray.dashboard.utils
  from opencensus.stats import stats
  import ray._private.prometheus_exporter
  from prometheus_client.core import REGISTRY
  from ray._private.metrics_agent import Gauge, MetricsAgent, Record
  from ray._private.ray_constants import DEBUG_AUTOSCALING_STATUS
  from ray.core.generated import reporter_pb2, reporter_pb2_grpc
  from ray.dashboard import k8s_utils
  from ray._raylet import WorkerID
label_desc: Use image node_id 1 to create a new ReporterAgent object from inherited base classes: dashboard_utils, reporter_pb2_grpc with example: obj = ReporterAgent(dashboard_agent)