docstr: Clean up stale components.
  
  Stale means the component is dead or unresponsive.
  
  Stale components won't be reported to Prometheus anymore.
docstr_tok: ["Clean","up","stale","components",".","Stale","means","the","component","is","dead","or","unresponsive",".","Stale","components","wo","n't","be","reported","to","Prometheus","anymore","."]
code: def clean_stale_components(self):
      """Clean up stale components.
  
      Stale means the component is dead or unresponsive.
  
      Stale components won't be reported to Prometheus anymore.
      """
      with self._components_lock:
          stale_components = []
          stale_component_ids = []
          for id, component in self._components.items():
              elapsed = time.monotonic() - component.last_reported_time
              if elapsed > self._component_timeout_s:
                  stale_component_ids.append(id)
                  logger.info(
                      "Metrics from a worker ({}) is cleaned up due to "
                      "timeout. Time since last report {}s".format(
                          id, elapsed
                      )
                  )
          for id in stale_component_ids:
              stale_components.append(self._components.pop(id))
          return stale_components
  
imports: import json
  import logging
  import os
  import re
  import threading
  import time
  import traceback
  from collections import namedtuple
  from typing import List, Tuple, Any, Dict
  from prometheus_client.core import CounterMetricFamily, GaugeMetricFamily, HistogramMetricFamily
  from opencensus.metrics.export.value import ValueDouble
  from opencensus.stats import aggregation
  from opencensus.stats import measure
  from opencensus.stats.view_manager import ViewManager
  from opencensus.stats.stats_recorder import StatsRecorder
  from opencensus.stats.base_exporter import StatsExporter
  from prometheus_client.core import Metric
  from opencensus.stats.aggregation_data import CountAggregationData, DistributionAggregationData, LastValueAggregationData
  from opencensus.stats.view import View
  from opencensus.tags import tag_key
  from opencensus.tags import tag_map
  from opencensus.tags import tag_value
  import ray
  from ray._raylet import GcsClient
  from ray.core.generated.metrics_pb2 import Metric
label_desc: Use image node_id 3 for calling the OpenCensusProxyCollector obj's underlying member method code with example usage: obj.clean_stale_components() and returns: stale_components