class_docstr: Container for all the COUNTER and GAUGE metrics extracted from an OpenMetrics endpoint.
class_docstr_tok: ["Container","for","all","the","COUNTER","and","GAUGE","metrics","extracted","from","an","OpenMetrics","endpoint","."]
code: def parse_open_metrics_endpoint(
      self,
  ) -> Dict[str, Union[str, int, float]]:
      assert prometheus_client_parser is not None
      assert self._session is not None
  
      response = self._session.get(self.url, timeout=_REQUEST_TIMEOUT)
      response.raise_for_status()
  
      text = response.text
      measurement = {}
      for (
          family
      ) in prometheus_client_parser.text_string_to_metric_families(
          text
      ):
          if family.type not in ("counter", "gauge"):
              # todo: add support for other metric types?
              # todo: log warning about that?
              continue
          for sample in family.samples:
              name, labels, value = (
                  sample.name,
                  sample.labels,
                  sample.value,
              )
  
              if not _should_capture_metric(
                  self.name,
                  name,
                  tuple(labels.items()),
                  self.filters_tuple,
              ):
                  continue
  
              # md5 hash of the labels
              label_hash = hashutil._md5(
                  str(labels).encode("utf-8")
              ).hexdigest()
              if label_hash not in self.label_map[name]:
                  # store the index of the label hash in the label map
                  self.label_map[name][label_hash] = len(
                      self.label_map[name]
                  )
                  # store the labels themselves
                  self.label_hashes[label_hash] = labels
              index = self.label_map[name][label_hash]
              measurement[f"{name}.{index}"] = value
  
      return measurement
  
imports: import logging
  import re
  import sys
  import threading
  from collections import defaultdict, deque
  from functools import lru_cache
  from types import ModuleType
  from typing import TYPE_CHECKING, Dict, List, Mapping, Sequence, Tuple, Union
  import requests
  import requests.adapters
  import urllib3
  import wandb
  from wandb.sdk.lib import hashutil, telemetry
  from .aggregators import aggregate_last, aggregate_mean
  from .interfaces import Interface, Metric, MetricsMonitor
label_desc: Use image node_id 4 for calling the OpenMetricsMetric obj's underlying member method code with example usage: obj.parse_open_metrics_endpoint() and returns: measurement