code: def test_basic_custom_metrics(metric_mock):
      # Make sure each of metric works as expected.
      # -- Counter --
      count = Counter("count", tag_keys=("a",))
      with pytest.raises(TypeError):
          count.inc("hi")
      with pytest.raises(ValueError):
          count.inc(0)
      with pytest.raises(ValueError):
          count.inc(-1)
      count._metric = metric_mock
      count.inc(1, {"a": "1"})
      metric_mock.record.assert_called_with(1, tags={"a": "1"})
  
      # -- Gauge --
      gauge = Gauge("gauge", description="gauge")
      gauge._metric = metric_mock
      gauge.record(4)
      metric_mock.record.assert_called_with(4, tags={})
  
      # -- Histogram
      histogram = Histogram(
          "hist",
          description="hist",
          boundaries=[1.0, 3.0],
          tag_keys=("a", "b"),
      )
      histogram._metric = metric_mock
      tags = {"a": "10", "b": "b"}
      histogram.observe(8, tags=tags)
      metric_mock.record.assert_called_with(8, tags=tags)
  
imports: import signal
  import json
  import os
  import pathlib
  import sys
  import requests
  from pprint import pformat
  from unittest.mock import MagicMock
  import numpy
  import pytest
  import ray
  from ray.util.state import list_nodes
  from ray._private.metrics_agent import PrometheusServiceDiscoveryWriter
  from ray._private.ray_constants import PROMETHEUS_SERVICE_DISCOVERY_FILE
  from ray._private.test_utils import SignalActor, fetch_prometheus, fetch_prometheus_metrics, get_log_batch, wait_for_condition, raw_metrics
  from ray.autoscaler._private.constants import AUTOSCALER_METRIC_PORT
  from ray.dashboard.consts import DASHBOARD_METRIC_PORT
  from ray.util.metrics import Counter, Gauge, Histogram
label_desc: Use image node_id 9 for calling a global function with example usage: test_basic_custom_metrics(metric_mock) without return types