code: def test_counter(init_firstly):
      if init_firstly:
          init_metrics()
      c = Metrics.counter(
          "test_counter", "A test counter", ("service", "tenant")
      )
      assert c.name == "test_counter"
      assert c.description == "A test counter"
      assert c.tag_keys == ("service", "tenant")
      assert c.type == "Counter"
      if not init_firstly:
          init_metrics()
      c.record(1, {"service": "mars", "tenant": "test"})
      c.record(2, {"service": "mars", "tenant": "test"})
      assert c.value == 3
  
file_path: mars/mars/metrics/tests/test_metric_api.py
imports: import pytest
  from random import random
  from ..None import api
  from ..api import init_metrics, Metrics, _percentile_builder, Percentile, record_time_cost_percentile, shutdown_metrics
label_desc: Use image node_id 3 for calling a global function with example usage: test_counter(init_firstly) without return types