code: def test_metrics_agent_export_format_correct(get_agent):
      """
      Verifies that there is one metric per metric name and not one
      per metric name + tag combination.
      Also verifies that the prometheus output is in the right format.
      """
      namespace = "test"
      agent, agent_port = get_agent
  
      # Record a new gauge.
      metric_name = "test"
      test_gauge = Gauge(metric_name, "desc", "unit", ["tag"])
      record_a = Record(
          gauge=test_gauge,
          value=3,
          tags={"tag": "a"},
      )
      agent.record_and_export([record_a])
  
      # Record a different tag.
      record_b = Record(
          gauge=test_gauge,
          value=4,
          tags={"tag": "b"},
      )
      agent.record_and_export([record_b])
  
      # Record more than 1 gauge.
      metric_name_2 = "test2"
      test_gauge_2 = Gauge(metric_name_2, "desc", "unit", ["tag"])
      record_c = Record(
          gauge=test_gauge_2,
          value=1,
          tags={"tag": "c"},
      )
      agent.record_and_export([record_c])
  
      # Basic assertions
      name, samples = get_metric(
          get_prom_metric_name(namespace, metric_name_2), agent_port
      )
      assert name == get_prom_metric_name(namespace, metric_name_2)
      assert len(samples) == 1
      assert samples[0].value == 1
      assert samples[0].labels == {"tag": "c"}
  
      name, samples = get_metric(
          get_prom_metric_name(namespace, metric_name), agent_port
      )
      assert name == get_prom_metric_name(namespace, metric_name)
      assert len(samples) == 2
      assert samples[0].value == 3
      assert samples[0].labels == {"tag": "a"}
      assert samples[1].value == 4
      assert samples[1].labels == {"tag": "b"}
  
      # Assert there is not multiple HELP text per metric
      # Need to manually parse the prometheus output because the official
      # `prometheus_client.parser` is more lenient than the actual
      # specification and ignores the multiple HELP / TYPE comments.
      metrics_page = "localhost:{}".format(agent_port)
      _, response = list(fetch_raw_prometheus([metrics_page]))[0]
      assert response.count("# HELP test_test desc") == 1
      assert response.count("# TYPE test_test gauge") == 1
      assert response.count("# HELP test_test2 desc") == 1
      assert response.count("# TYPE test_test2 gauge") == 1
  
imports: import os
  import time
  import sys
  import pytest
  import ray._private.prometheus_exporter
  from typing import List
  from opencensus.stats.view_manager import ViewManager
  from opencensus.stats.stats_recorder import StatsRecorder
  from opencensus.stats import execution_context
  from prometheus_client.core import REGISTRY
  from ray._private.metrics_agent import Gauge, MetricsAgent, Record, RAY_WORKER_TIMEOUT_S
  from ray._private.services import new_port
  from ray.core.generated.metrics_pb2 import Metric, MetricDescriptor, Point, LabelKey, TimeSeries, LabelValue
  from ray._raylet import WorkerID
  from ray._private.test_utils import fetch_prometheus_metrics, fetch_raw_prometheus, wait_for_condition
label_desc: Use image node_id 12 for calling a global function with example usage: test_metrics_agent_export_format_correct(get_agent) without return types