code: def get_metrics_report(
      metrics_client: PrometheusClient,
      serve_kind: str,
  ) -> list[dict[str, str | float]]:
      """
      Get Prometheus metrics reports from the metrics client. This will be used to determine tracking events.
      If the return metrics are legacy metrics, the metrics will have prefix BENTOML_, otherwise they will have prefix bentoml_
  
      Args:
          metrics_client: Instance of bentoml._internal.server.metrics.prometheus.PrometheusClient
          grpc: Whether the metrics are for gRPC server.
  
      Returns:
          A tuple of a list of metrics and an optional boolean to determine whether the return metrics are legacy metrics.
      """
      for metric in metrics_client.text_string_to_metric_families():
          metric_type = t.cast("str", metric.type)  # type: ignore (we need to cast due to no prometheus types)
          metric_name = t.cast("str", metric.name)  # type: ignore (we need to cast due to no prometheus types)
          metric_samples = t.cast("list[Sample]", metric.samples)  # type: ignore (we need to cast due to no prometheus types)
          if metric_type != "counter":
              continue
          # We only care about the counter metrics.
          assert metric_type == "counter"
          if serve_kind == "grpc":
              _filters: list[
                  t.Callable[[list[Sample]], list[Sample]]
              ] = [
                  lambda samples: [
                      s for s in samples if "api_name" in s.labels
                  ]
              ]
          elif serve_kind == "http":
              _filters = [
                  lambda samples: [
                      s
                      for s in samples
                      if not s.labels["endpoint"].startswith(
                          "/static_content/"
                      )
                  ],
                  lambda samples: [
                      s
                      for s in samples
                      if s.labels["endpoint"] not in EXCLUDE_PATHS
                  ],
                  lambda samples: [
                      s for s in samples if "endpoint" in s.labels
                  ],
              ]
          else:
              raise NotImplementedError(
                  "Unknown serve kind %s" % serve_kind
              )
          # If metrics prefix is BENTOML_, this is legacy metrics
          if metric_name.endswith("_request") and (
              metric_name.startswith("bentoml_")
              or metric_name.startswith("BENTOML_")
          ):
              return filter_metrics(metric_samples, *_filters)
  
      return []
  
imports: from __future__ import annotations
  import contextlib
  import logging
  import os
  import secrets
  import threading
  import typing
  from datetime import datetime
  from datetime import timezone
  from functools import lru_cache
  from functools import wraps
  from typing import TYPE_CHECKING
  import attr
  import httpx
  from simple_di import Provide
  from simple_di import inject
  from ...configuration import get_debug_mode
  from ...configuration.containers import BentoMLContainer
  from ...utils import compose
  from .schemas import CommonProperties
  from .schemas import EventMeta
  from .schemas import ServeInitEvent
  from .schemas import ServeUpdateEvent
  from .schemas import TrackingPayload
label_desc: Use image node_id 10 for calling a global function with example usage: get_metrics_report(metrics_client, serve_kind) and returns: list, filter_metrics