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 aggregate(self) -> dict:
      if not self.samples:
          return {}
  
      prefix = f"{_PREFIX}.{self.name}."
  
      stats = {}
      for key in self.samples[0].keys():
          samples = [s[key] for s in self.samples if key in s]
          if samples and all(
              isinstance(s, (int, float)) for s in samples
          ):
              stats[f"{prefix}{key}"] = aggregate_mean(samples)
          else:
              stats[f"{prefix}{key}"] = aggregate_last(samples)
      return stats
  
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 7 for calling the OpenMetricsMetric obj's underlying member method code with example usage: obj.aggregate() and returns: stats, dict